@@ -53,6 +53,11 @@ QgsOgrFeatureIterator::QgsOgrFeatureIterator( QgsOgrFeatureSource *source, bool
53
53
, mSymbolType( QgsSymbol::symbolTypeForGeometryType( QgsWkbTypes::geometryType( source->mWkbType ) ) )
54
54
{
55
55
56
+ if ( mSharedDS )
57
+ {
58
+ mTransactionDSLocker = new QMutexLocker ( &mSharedDS ->sharedDSMutex () );
59
+ }
60
+
56
61
/* When inside a transaction for GPKG/SQLite and fetching fid(s) we might be nested inside an outer fetching loop,
57
62
* (see GH #39178) so we need to skip all calls that might reset the reading (rewind) to avoid an endless loop in the
58
63
* outer fetching iterator that uses the same connection.
@@ -124,7 +129,7 @@ QgsOgrFeatureIterator::QgsOgrFeatureIterator( QgsOgrFeatureSource *source, bool
124
129
}
125
130
}
126
131
}
127
- QMutexLocker locker ( mSharedDS ? &mSharedDS ->mutex () : nullptr );
132
+ // QMutexLocker locker( mSharedDS ? &mSharedDS->mutex() : nullptr );
128
133
129
134
if ( mRequest .destinationCrs ().isValid () && mRequest .destinationCrs () != mSource ->mCrs )
130
135
{
@@ -280,6 +285,7 @@ QgsOgrFeatureIterator::QgsOgrFeatureIterator( QgsOgrFeatureSource *source, bool
280
285
QgsOgrFeatureIterator::~QgsOgrFeatureIterator ()
281
286
{
282
287
close ();
288
+ delete mTransactionDSLocker ;
283
289
}
284
290
285
291
bool QgsOgrFeatureIterator::nextFeatureFilterExpression ( QgsFeature &f )
@@ -372,8 +378,7 @@ void QgsOgrFeatureIterator::setInterruptionChecker( QgsFeedback *interruptionChe
372
378
373
379
bool QgsOgrFeatureIterator::fetchFeature ( QgsFeature &feature )
374
380
{
375
- QMutexLocker locker ( mSharedDS ? &mSharedDS ->mutex () : nullptr );
376
-
381
+ // QMutexLocker locker( mSharedDS ? &mSharedDS->mutex() : nullptr );
377
382
QgsCPLHTTPFetchOverrider oCPLHTTPFetcher ( mAuthCfg , mInterruptionChecker );
378
383
QgsSetCPLHTTPFetchOverriderInitiatorClass ( oCPLHTTPFetcher, QStringLiteral ( " QgsOgrFeatureIterator" ) )
379
384
@@ -469,8 +474,7 @@ void QgsOgrFeatureIterator::resetReading()
469
474
470
475
bool QgsOgrFeatureIterator::rewind ()
471
476
{
472
- QMutexLocker locker ( mSharedDS ? &mSharedDS ->mutex () : nullptr );
473
-
477
+ // QMutexLocker locker( mSharedDS ? &mSharedDS->mutex() : nullptr );
474
478
if ( mClosed || !mOgrLayer )
475
479
return false ;
476
480
@@ -487,9 +491,13 @@ bool QgsOgrFeatureIterator::close()
487
491
if ( mSharedDS )
488
492
{
489
493
iteratorClosed ();
490
-
494
+ /* if ( mSharedDS )
495
+ {
496
+ mSharedDS->sharedDSMutex().unlock();
497
+ }*/
491
498
mOgrLayer = nullptr ;
492
499
mSharedDS .reset ();
500
+
493
501
mClosed = true ;
494
502
return true ;
495
503
}
@@ -525,6 +533,9 @@ bool QgsOgrFeatureIterator::close()
525
533
mOgrLayer = nullptr ;
526
534
527
535
mClosed = true ;
536
+
537
+
538
+
528
539
return true ;
529
540
}
530
541
0 commit comments