Bug report #3366

QgsVectorLayer.committedFeaturesRemoved causes crash in Python

Added by Chris Crook over 13 years ago. Updated over 13 years ago.

Assignee:Borys Jurgiel
Category:Python plugins
Affected QGIS version: Regression?:No
Operating System:Windows Easy fix?:No
Pull Request or Patch supplied: Resolution:fixed
Crashes QGIS or corrupts data: Copied to github as #:13426


To replicate the problem ..

1) Open a new QGis project

2) Open a python console window

3) Enter the following code

from [[PyQt]]4.QtCore import *
def handler():
    print "Deleting features" 

# Create a scratch layer and connect to committedFeaturesRemoved signal
name = "Test" 
layer = [[QgsVectorLayer]](type, name, "memory")
QObject.connect(layer, SIGNAL("committedFeaturesRemoved(const QString &, const [[QgsFeatureIds]] & )"),handler)

This will create a layer called test

4) Set the layer to be editable

5) Add a point to the layer

6) Commit the change (save the layer)

7) Select the point

8) Delete the point

9) Commit the change - this causes the crash.

This happens consistently for me in QGis versions 1.6 and 1.7 r14962

Operating system is windows XP SP3

I've had a look at it as far as I can in the Visual Studio debugger. The crash appears to happen in the generated moc_.. file where the python signal is implemented, and the message is:

Unhandled exception at 0x0372ba7c in qgis.exe: 0xC000001E:  An attempt was made to execute an   invalid lock sequence.


#1 Updated by Chris Crook over 13 years ago

The line

def handler():

should probably read

def handler(arg1,arg2):

But it doesn't make any difference

#2 Updated by Martin Dobias over 13 years ago

When running the code in python console I get this (for the connect() call):

Traceback (most recent call last):
  File "<input>", line 1, in <module>
[[TypeError]]: type 'QgsFeatureIds' is not supported as a slot argument type

(this is sip v4.10.5 and pyqt v4.7.4)

It doesn't crash for me. I see several possible causes of your crash:

* the committed*(...) signals were not known by sip (they were added in qgis 1.6 but not also to pyqgis)

I have fixed both in commit:1d66171f (SVN r14979) - please give it another try with new trunk and close this bug if it works now.


#3 Updated by Chris Crook over 13 years ago

  • Resolution set to fixed
  • Status changed from Open to Closed

Brilliant.. thanks! This has fixed it (and I've set the status accordingly)

Looks like Windows doesn't handle this as well .. just dies when it can't handle the argument type.

Many thanks

Also available in: Atom PDF