Skip to content

Commit 44ce897

Browse files
committed
Use QPointer instead of QWeakPointer
1 parent d2f52bf commit 44ce897

File tree

2 files changed

+6
-3
lines changed

2 files changed

+6
-3
lines changed

src/core/qgsvectorlayerutils.cpp

+4-1
Original file line numberDiff line numberDiff line change
@@ -498,12 +498,15 @@ QgsFeature QgsVectorLayerUtils::duplicateFeature( QgsVectorLayer *layer, const Q
498498
return newFeature;
499499
}
500500

501-
std::unique_ptr<QgsVectorLayerFeatureSource> QgsVectorLayerUtils::getFeatureSource( QWeakPointer<QgsVectorLayer> layer )
501+
std::unique_ptr<QgsVectorLayerFeatureSource> QgsVectorLayerUtils::getFeatureSource( QPointer<QgsVectorLayer> layer )
502502
{
503503
std::unique_ptr<QgsVectorLayerFeatureSource> featureSource;
504504

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

509512
if ( lyr )

src/core/qgsvectorlayerutils.h

+2-2
Original file line numberDiff line numberDiff line change
@@ -157,7 +157,7 @@ class CORE_EXPORT QgsVectorLayerUtils
157157
static QgsFeature duplicateFeature( QgsVectorLayer *layer, const QgsFeature &feature, QgsProject *project, int depth, QgsDuplicateFeatureContext &duplicateFeatureContext SIP_OUT );
158158

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

172172

0 commit comments

Comments
 (0)