Skip to content

Commit

Permalink
Merge pull request #5692 from manisandro/afsshareddata_mutex
Browse files Browse the repository at this point in the history
[ArcGIS REST] Add missing mutex to QgsAfsProvider (fixes #17513)
  • Loading branch information
manisandro committed Nov 22, 2017
2 parents db3c93c + e9309ee commit d6d4097
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/providers/arcgisrest/qgsafsprovider.cpp
Expand Up @@ -199,7 +199,7 @@ QgsRectangle QgsAfsProvider::extent() const

void QgsAfsProvider::reloadData()
{
mSharedData->mCache.clear();
mSharedData->clearCache();
}


Expand Down
8 changes: 8 additions & 0 deletions src/providers/arcgisrest/qgsafsshareddata.cpp
Expand Up @@ -17,8 +17,16 @@
#include "qgsarcgisrestutils.h"
#include "qgslogger.h"

void QgsAfsSharedData::clearCache()
{
QMutexLocker locker( &mMutex );
mCache.clear();
}

bool QgsAfsSharedData::getFeature( QgsFeatureId id, QgsFeature &f, bool fetchGeometry, const QList<int> & /*fetchAttributes*/, const QgsRectangle &filterRect )
{
QMutexLocker locker( &mMutex );

// If cached, return cached feature
QMap<QgsFeatureId, QgsFeature>::const_iterator it = mCache.constFind( id );
if ( it != mCache.constEnd() )
Expand Down
3 changes: 3 additions & 0 deletions src/providers/arcgisrest/qgsafsshareddata.h
Expand Up @@ -17,6 +17,7 @@
#define QGSAFSSHAREDDATA_H

#include <QObject>
#include <QMutex>
#include "qgsfields.h"
#include "qgsfeature.h"
#include "qgsdatasourceuri.h"
Expand All @@ -33,11 +34,13 @@ class QgsAfsSharedData : public QObject
const QgsFields &fields() const { return mFields; }
QgsRectangle extent() const { return mExtent; }
QgsCoordinateReferenceSystem crs() const { return mSourceCRS; }
void clearCache();

bool getFeature( QgsFeatureId id, QgsFeature &f, bool fetchGeometry, const QList<int> &fetchAttributes, const QgsRectangle &filterRect = QgsRectangle() );

private:
friend class QgsAfsProvider;
QMutex mMutex;
QgsDataSourceUri mDataSource;
QgsRectangle mExtent;
QgsWkbTypes::Type mGeometryType = QgsWkbTypes::Unknown;
Expand Down

0 comments on commit d6d4097

Please sign in to comment.