Skip to content
Permalink
Browse files

Merge pull request #6603 from slarosa/fix_18435

Fixes #18435: QGIS crash when deleting auxiliary layer
  • Loading branch information
luipir committed Mar 15, 2018
2 parents d907ba0 + 74689df commit d771991a01ffb77a90fa14a2bd786764b15763fc
Showing with 22 additions and 1 deletion.
  1. +2 −1 src/core/qgsvectorlayer.cpp
  2. +20 −0 tests/src/python/test_qgsauxiliarystorage.py
@@ -4304,7 +4304,8 @@ void QgsVectorLayer::setAuxiliaryLayer( QgsAuxiliaryLayer *alayer )
}

mAuxiliaryLayer.reset( alayer );
mAuxiliaryLayer->setParent( this );
if ( mAuxiliaryLayer )
mAuxiliaryLayer->setParent( this );
updateFields();
}

@@ -361,6 +361,26 @@ def testClear(self):
al.clear()
self.assertEqual(al.featureCount(), 0)

def testSetAuxiliaryLayer(self):
s = QgsAuxiliaryStorage()
self.assertTrue(s.isValid())

# Create a new auxiliary layer with 'pk' as key
vl = createLayer()
pkf = vl.fields().field(vl.fields().indexOf('pk'))
al = s.createAuxiliaryLayer(pkf, vl)
self.assertTrue(al.isValid())
vl.setAuxiliaryLayer(al)

self.assertIsNotNone(vl.auxiliaryLayer())

# Clear auxiliary layer
al.clear()
# Remove auxiliary layer
vl.setAuxiliaryLayer()

self.assertIsNone(vl.auxiliaryLayer())

def testCreateProperty(self):
s = QgsAuxiliaryStorage()
self.assertTrue(s.isValid())

0 comments on commit d771991

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