Skip to content

Commit

Permalink
Fix unthread-safe access from tests
Browse files Browse the repository at this point in the history
  • Loading branch information
nyalldawson committed Dec 13, 2022
1 parent 086c6c8 commit 93bbe68
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions tests/src/core/testqgsconnectionpool.cpp
Expand Up @@ -20,6 +20,7 @@
#include "qgspoint.h"
#include "qgslinestring.h"
#include "qgsvectorlayer.h"
#include "qgsvectorlayerfeatureiterator.h"
#include <QEventLoop>
#include <QObject>
#include <QTemporaryFile>
Expand All @@ -39,14 +40,14 @@ class TestQgsConnectionPool: public QObject
private:
struct ReadJob
{
explicit ReadJob( QgsVectorLayer *_layer ) : layer( _layer ) {}
QgsVectorLayer *layer = nullptr;
explicit ReadJob( QgsVectorLayer *_layer ) : source( std::make_shared< QgsVectorLayerFeatureSource >( _layer ) ) {}
std::shared_ptr< QgsVectorLayerFeatureSource> source;
QList<QgsFeature> features;
};

static void processJob( ReadJob &job )
{
QgsFeatureIterator it = job.layer->getFeatures();
QgsFeatureIterator it = job.source->getFeatures();
QgsFeature f;
while ( it.nextFeature( f ) )
{
Expand Down

0 comments on commit 93bbe68

Please sign in to comment.