Bug report #15088
Segmentation fault when using layersRemoved SIGNAL
Status: | Closed | ||
---|---|---|---|
Priority: | Severe/Regression | ||
Assignee: | - | ||
Category: | Vectors | ||
Affected QGIS version: | 2.14.2 | Regression?: | No |
Operating System: | GNU/Linux | Easy fix?: | No |
Pull Request or Patch supplied: | No | Resolution: | |
Crashes QGIS or corrupts data: | No | Copied to github as #: | 23030 |
Description
There seems to be an issue connecting the SIGNAL layersRemoved from QgsMapLayerRegistry.
For example, if I save this script to a file, and run it from the Linux terminal:
################################################
import unittest
from qgis.core import QgsApplication, QgsMapLayerRegistry
class SIGNALTest( unittest.TestCase ):
def setUp( self ):
app = QgsApplication([], True)
QgsApplication.setPrefixPath("/usr", True)
QgsApplication.initQgis()
QgsMapLayerRegistry.instance().layersRemoved.connect( self.myFunction )
def myFunction( self, layerIds ):
print "Called!"
def test1( self ):
self.assertEqual(1,1)
def tearDown( self ):
QgsApplication.exitQgis()
if name == "__main__":
unittest.main()
################################################
I get the following result:
##########
Called!
.
----------------------------------------------------------------------
Ran 1 test in 0.119s
OK
Segmentation fault
###########
If, on the contrary, I comment out the line where the connection is set or if I use other signals such as layerRemoved or layersAdded instead of layersRemoved, I get:
###########
.
----------------------------------------------------------------------
Ran 1 test in 0.111s
OK ###########
I'm using QGIS 2.14.2 on a GNU/Linux machine.
Associated revisions
QgsMapLayerRegistry::removeMapLayers don't emit signals when empty
Fix #15088
QgsMapLayerRegistry::removeMapLayers don't emit signals when empty
Fix #15088
History
#1 Updated by René-Luc ReLuc over 8 years ago
- Target version changed from Future Release - Lower Priority to Version 2.14
- Priority changed from Normal to Severe/Regression
- Category changed from Python plugins to Vectors
We encountered the same behavoir on QGIS Server.
The crash is due to `QgsEditorWidgetRegistry::mapLayerWillBeRemoved` when the cast is done `QgsVectorLayer* vl = qobject_cast<QgsVectorLayer*>( mapLayer );` QGIS crashed.
#2 Updated by Anonymous over 8 years ago
- Status changed from Open to Closed
Fixed in changeset 4b0df5bc5b71523ad35db050c57ca3c04c2b6d1e.