Skip to content

Commit

Permalink
Use QPointer instead of QWeakPointer
Browse files Browse the repository at this point in the history
  • Loading branch information
m-kuhn committed Sep 4, 2018
1 parent d2f52bf commit 44ce897
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 3 deletions.
5 changes: 4 additions & 1 deletion src/core/qgsvectorlayerutils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -498,12 +498,15 @@ QgsFeature QgsVectorLayerUtils::duplicateFeature( QgsVectorLayer *layer, const Q
return newFeature;
}

std::unique_ptr<QgsVectorLayerFeatureSource> QgsVectorLayerUtils::getFeatureSource( QWeakPointer<QgsVectorLayer> layer )
std::unique_ptr<QgsVectorLayerFeatureSource> QgsVectorLayerUtils::getFeatureSource( QPointer<QgsVectorLayer> layer )
{
std::unique_ptr<QgsVectorLayerFeatureSource> featureSource;

auto getFeatureSource = [ layer, &featureSource ]
{
#if QT_VERSION >= QT_VERSION_CHECK( 5, 10, 0 )
Q_ASSERT( QThread::currentThread() == qApp->thread() );
#endif
QgsVectorLayer *lyr = layer.data();

if ( lyr )
Expand Down
4 changes: 2 additions & 2 deletions src/core/qgsvectorlayerutils.h
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,7 @@ class CORE_EXPORT QgsVectorLayerUtils
static QgsFeature duplicateFeature( QgsVectorLayer *layer, const QgsFeature &feature, QgsProject *project, int depth, QgsDuplicateFeatureContext &duplicateFeatureContext SIP_OUT );

/**
* Gets the feature source from a weak QgsVectorLayer pointer.
* Gets the feature source from a QgsVectorLayer pointer.
* This method is thread-safe but will block the main thread for execution. Executing it from the main
* thread is safe too.
* This should be used in scenarios, where a ``QWeakPointer<QgsVectorLayer>`` is kept in a thread
Expand All @@ -166,7 +166,7 @@ class CORE_EXPORT QgsVectorLayerUtils
* \note Requires Qt >= 5.10 to make use of the thread-safe implementation
* \since QGIS 3.4
*/
static std::unique_ptr<QgsVectorLayerFeatureSource> getFeatureSource( QWeakPointer<QgsVectorLayer> layer ) SIP_SKIP;
static std::unique_ptr<QgsVectorLayerFeatureSource> getFeatureSource( QPointer<QgsVectorLayer> layer ) SIP_SKIP;
};


Expand Down

0 comments on commit 44ce897

Please sign in to comment.