Opened 13 years ago

Closed 13 years ago

#3366 closed bug (fixed)

QgsVectorLayer.committedFeaturesRemoved causes crash in Python

Reported by: ccrook Owned by: borysiasty
Priority: critical: causes crash or data corruption Milestone: Version 1.7.0
Component: Python plugins and bindings Version: 1.6.0
Keywords: Cc:
Must Fix for Release: No Platform: Windows
Platform Version: XP SP3 Awaiting user input: no

Description

To replicate the problem ..

1) Open a new QGis project

2) Open a python console window

3) Enter the following code

from PyQt4.QtCore import *
def handler():
    print "Deleting features"

# Create a scratch layer and connect to committedFeaturesRemoved signal
type="Point"
name = "Test"
layer = QgsVectorLayer(type, name, "memory")
QgsMapLayerRegistry.instance().addMapLayer(layer)
qgis.utils.iface.mapCanvas().setCurrentLayer(layer)
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.

Change History (3)

comment:1 by ccrook, 13 years ago

The line

def handler():

should probably read

def handler(arg1,arg2):

But it doesn't make any difference

comment:2 by wonder, 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:

  • QgsFeatureIds was not known by sip
  • 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 r14978 - please give it another try with new trunk and close this bug if it works now.

Martin

in reply to:  2 comment:3 by ccrook, 13 years ago

Resolution: fixed
Status: newclosed

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 Chris

Note: See TracTickets for help on using tickets.