Skip to content

Commit

Permalink
Merge pull request #6603 from slarosa/fix_18435
Browse files Browse the repository at this point in the history
Fixes #18435: QGIS crash when deleting auxiliary layer
  • Loading branch information
luipir committed Mar 15, 2018
2 parents d907ba0 + 74689df commit d771991
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 1 deletion.
3 changes: 2 additions & 1 deletion src/core/qgsvectorlayer.cpp
Expand Up @@ -4304,7 +4304,8 @@ void QgsVectorLayer::setAuxiliaryLayer( QgsAuxiliaryLayer *alayer )
}

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

Expand Down
20 changes: 20 additions & 0 deletions tests/src/python/test_qgsauxiliarystorage.py
Expand Up @@ -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())
Expand Down

0 comments on commit d771991

Please sign in to comment.