File tree 2 files changed +22
-1
lines changed
2 files changed +22
-1
lines changed Original file line number Diff line number Diff line change @@ -4304,7 +4304,8 @@ void QgsVectorLayer::setAuxiliaryLayer( QgsAuxiliaryLayer *alayer )
4304
4304
}
4305
4305
4306
4306
mAuxiliaryLayer .reset ( alayer );
4307
- mAuxiliaryLayer ->setParent ( this );
4307
+ if ( mAuxiliaryLayer )
4308
+ mAuxiliaryLayer ->setParent ( this );
4308
4309
updateFields ();
4309
4310
}
4310
4311
Original file line number Diff line number Diff line change @@ -361,6 +361,26 @@ def testClear(self):
361
361
al .clear ()
362
362
self .assertEqual (al .featureCount (), 0 )
363
363
364
+ def testSetAuxiliaryLayer (self ):
365
+ s = QgsAuxiliaryStorage ()
366
+ self .assertTrue (s .isValid ())
367
+
368
+ # Create a new auxiliary layer with 'pk' as key
369
+ vl = createLayer ()
370
+ pkf = vl .fields ().field (vl .fields ().indexOf ('pk' ))
371
+ al = s .createAuxiliaryLayer (pkf , vl )
372
+ self .assertTrue (al .isValid ())
373
+ vl .setAuxiliaryLayer (al )
374
+
375
+ self .assertIsNotNone (vl .auxiliaryLayer ())
376
+
377
+ # Clear auxiliary layer
378
+ al .clear ()
379
+ # Remove auxiliary layer
380
+ vl .setAuxiliaryLayer ()
381
+
382
+ self .assertIsNone (vl .auxiliaryLayer ())
383
+
364
384
def testCreateProperty (self ):
365
385
s = QgsAuxiliaryStorage ()
366
386
self .assertTrue (s .isValid ())
You can’t perform that action at this time.
0 commit comments