Bug report #13740

selectionChanged signal emitted on Mac without arguments

Added by Jeff Cavner about 9 years ago. Updated about 9 years ago.

Status:Closed
Priority:Normal
Assignee:-
Category:Python plugins
Affected QGIS version:2.12.0 Regression?:No
Operating System:OSX Easy fix?:No
Pull Request or Patch supplied:No Resolution:
Crashes QGIS or corrupts data:No Copied to github as #:21767

Description

On OSX Yosemite, 10.10.5, both QGIS version 2.10 and 2.12 (KyngChaos installer), GDAL 1.11., When selectionChanged signal for QgsVectorLayer is connected to a user defined slot and the signal is emitted it doesn't send the selected, unselected, clearAndSelect arguments. Programmaticly using select and setSelectedFeatures and manually selecting cause this behaviour. The problem does not exist for Windows 7 Professional or Ubuntu, only OSX.

So:

lyr = iface.activeLayer()

def mySlot(selected, unselected, clearAndSelect):
print "here"

lyr.selectionChanged.connect(mySlot)

Make a Selection on the canvas

TypeError: mySlot() takes exactly 3 arguments (0 given)

Associated revisions

Revision 5f864229
Added by Jürgen Fischer about 9 years ago

  • fix QgsFeatureIds typedef (fixes missing signal
    QgsVectorLayer.featuresDeleted and others; fixes #13740)
  • add missing notes for PyNames
  • include some missing new methods in bindings

(backported from commit b5794b2)

Revision b29cbbc6
Added by Jürgen Fischer about 9 years ago

sip bindings: fix QgsFeatureIds typedef (fixes missing signal
QgsVectorLayer.featuresDeleted and others; fixes #13740)

(backported from commit b5794b2)

History

#1 Updated by Giovanni Manghi about 9 years ago

  • Priority changed from Severe/Regression to Normal
  • Target version deleted (Version 2.12)

#2 Updated by Jürgen Fischer about 9 years ago

  • Subject changed from selectionChanged signal emited on Mac without arguments to selectionChanged signal emitted on Mac without arguments

#3 Updated by Sebastian Dietrich about 9 years ago

Note that selectionChanged is an overloaded signal that comes in two variants, one with 3 arguments and one without any arguments:

signals:
  void selectionChanged( const QgsFeatureIds selected, const QgsFeatureIds deselected, const bool clearAndSelect );
  void selectionChanged();

Apparently the overload that is used by default on Windows is the first one, while on Mac the second one is used.

As a workaround try specifying the exact overload you want to connect:

lyr.selectionChanged['QgsFeatureIds', 'QgsFeatureIds', bool].connect(mySlot)

This also works on Windows.

#4 Updated by Nyall Dawson about 9 years ago

Can you test with master? This should already be fixed

#5 Updated by Jeff Lifemapper Project about 9 years ago

specifying the exact overload in mac doesn't work, for 2.12 or for 2.8.4 (returned to LTR on KyngChaos just to make sure)

lyr.selectionChanged['QgsFeatureIds', 'QgsFeatureIds', bool].connect(mySlot)

TypeError: C++ type 'QgsFeatureIds' is not supported as a signal argument type

#6 Updated by Nyall Dawson about 9 years ago

  • Status changed from Open to Feedback

Hi Jeff,

Can you test with a nightly snapshot please? We want to verify if changes made a few weeks ago fixed this, but they are NOT included in 2.12/2.8.4

#7 Updated by Jürgen Fischer about 9 years ago

fixed in b5794b2f

#8 Updated by Jeff Lifemapper Project about 9 years ago

Yes, I found the nightly at http://qgis.dakotacarto.com/, and tested 2.13 dev. It seems to work, both as the default (sending the selected, deselected, clear and Select by default), and the 'QgsFeatureIds' doesn't throw an error should you have to specify the exact overload.

Thank you

#9 Updated by Jürgen Fischer about 9 years ago

  • Status changed from Feedback to Closed

Also available in: Atom PDF