Skip to content

workaround PYSIDE-2487 for pen parameter#2844

Merged
j9ac9k merged 3 commits intopyqtgraph:masterfrom
pijyoi:workaround-pyside2487
Oct 14, 2023
Merged

workaround PYSIDE-2487 for pen parameter#2844
j9ac9k merged 3 commits intopyqtgraph:masterfrom
pijyoi:workaround-pyside2487

Conversation

@pijyoi
Copy link
Copy Markdown
Contributor

@pijyoi pijyoi commented Oct 13, 2023

This PR workarounds a regression in PySide 6.5.3 that affects code in pyqtgraph's pen parameter.
(https://bugreports.qt.io/projects/PYSIDE/issues/PYSIDE-2487)

Note: Qt 6.5 is LTS and PySide 6.5.3 will be the last version to have non-commercial wheels.

Script to demonstrate that the proposed fix does disconnect the slot

from PySide6 import QtCore

class Parent(QtCore.QObject):
    sig = QtCore.Signal(object)

    def pslot(self, val):
        pass

class Child(Parent):
    pass

x = Child()
x.sig.connect(x.pslot)

# disconnecting slot defined in parent fails since PySide >= 6.5.3
# x.sig.disconnect(x.pslot) 

# disconnecting all slots works
x.sig.disconnect()

# show that slots are disconnected
x.dumpObjectInfo()

@pijyoi pijyoi force-pushed the workaround-pyside2487 branch from 2cd19b7 to bfee799 Compare October 14, 2023 03:23
note that the conditions triggering this RuntimeError are different
from the condition described in the issue PYSIDE-2487.

however the regression is likely from the same commit.
@pijyoi pijyoi force-pushed the workaround-pyside2487 branch from bfee799 to 47a60d8 Compare October 14, 2023 03:27
except RuntimeError:
# workaround https://bugreports.qt.io/projects/PYSIDE/issues/PYSIDE-2487
# that affects PySide 6.5.3
# Since the child param was freshly created by us, there can only have been one slot
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is it possible to guarantee this with assert p.receivers("_emitValueChanged(object, object)") == 1?

I tried various adaptations of arguments to receivers according to the docs example, but it always returns 0 when I try to test with a MWE. Do you know whether it works in Python? There aren't too many examples online...

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For PySide, the syntax is: assert p.receivers(QtCore.SIGNAL("sigValueChanged(PyObject,PyObject)")) == 1
The PySide syntax specific things are:

  1. PyObject
  2. QtCore.SIGNAL: PyQt has dropped it since moving to the new signal / slot syntax

@j9ac9k j9ac9k merged commit 7ab6fa3 into pyqtgraph:master Oct 14, 2023
@j9ac9k
Copy link
Copy Markdown
Member

j9ac9k commented Oct 14, 2023

Thanks @pijyoi !

@pijyoi pijyoi deleted the workaround-pyside2487 branch October 14, 2023 19:26
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants