[QGIS-Developer] Python slots don't get called when they're instance methods

G. Allegri giohappy at gmail.com
Wed Nov 28 15:51:12 PST 2018


So it seems something related to an old issue
https://issues.qgis.org/issues/6573

In effect I've always used old style signals and slots because new style
ones always gave me some problems (on Windows).

I will have to dig into others' plugins to verify.
Anyway it's curious to see that also Processing seems to use a workaround
in its PointTool: it emits its own signal instead of using the
QgsMapToolEmitPoint.canvasClicked signal. I've done the same to circumvent
the issue... But it doesn't apply to all the situations
https://github.com/qgis/QGIS/blob/master/python/plugins/processing/gui/PointMapTool.py

Giovanni

Il giorno gio 29 nov 2018, 00:39 Nyall Dawson <nyall.dawson at gmail.com> ha
scritto:

> On Thu, 29 Nov 2018 at 09:32, G. Allegri <giohappy at gmail.com> wrote:
> >
> > During the porting of a plugin to QGIS 3.x I'm facing the following when
> using Qgs* objects' signals (it doesn't happen with Qt widgets, etc.).
> > I'm using QGIS 3.4 on Window 10.
> >
> > If I have a Python class like the following:
> >
> > >class Foo():
> > >  def __init__(self):
> > >    QgsProject.instance().writeProject.connect(self.written)
> > >
> > >  def written(self, dom):
> > >    (do something)
> >
>
> Hmm - this code works fine for me!
>
> class Foo():
>   def __init__(self):
>     QgsProject.instance().writeProject.connect(self.written)
>
>   def written(self, dom):
>     print('bah')
>
> f=Foo()
>
> This is on Linux (Fedora).
>
> Nyall
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osgeo.org/pipermail/qgis-developer/attachments/20181129/6258fd13/attachment.html>


More information about the QGIS-Developer mailing list