Skip to content
Permalink
Browse files

Use QPointer instead of QWeakPointer

  • Loading branch information
m-kuhn committed Sep 4, 2018
1 parent d2f52bf commit 44ce8977d9fd2361d08e6be4829126882123804d
Showing with 6 additions and 3 deletions.
  1. +4 −1 src/core/qgsvectorlayerutils.cpp
  2. +2 −2 src/core/qgsvectorlayerutils.h
@@ -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 )
@@ -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
@@ -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;
};


0 comments on commit 44ce897

Please sign in to comment.
You can’t perform that action at this time.