Fix PySide6 6.2.2 breaking change#2132
Conversation
|
I'm not convinced that this is the ideal fix; there is something not write to me with having the signal/method conflict via multiple-inheritance. Given that # in GraphicsObject.__init__
self.parentChanged.connect(self._updateView)And get rid of Thoughts? EDIT: On second thought, that would be a whole new behavior change; instead perhaps we should change the diff to call |
|
So the following would be the MWE. Python rules say that M is searched before Q. from PySide6 import QtCore
class Q(QtCore.QObject):
signal = QtCore.Signal()
def method(self):
print('Q::method')
class M:
def signal(self):
print('M::signal')
def method(self):
print('M::method')
class C(M, Q):
def __init__(self):
Q.__init__(self)
M.__init__(self)
c = C()
c.method() # okay
c.signal() # problem on PySide6 6.2.2 |
|
Documenting here that calling |
|
I have a workaround that will successfully call self.parentChanged()to: import types
if isinstance(self.parentChanged, types.MethodType):
self.parentChanged()
else:
# workaround PySide6 6.2.2
getattr(self.__class__, 'parentChanged')(self)The |
e7e8e61 to
d215c43
Compare
|
Holding off on merging this until I can submit a bug-report with the pyside folks so I can reference the specific issue number; unfortunately I can't set 6.2.2 as the "affected version" for the submission process...hopefully I can do that tomorrow. |
This fixes an issue that came up in PySide6 6.2.2 where calls to GraphicsObject.parentChanged were passed to QGraphicsObject.parentChanged instead of GraphicsItem.parentChanged. In addition, this fix handles the case of ScaleBar.parentChanged as well, where specifying the specific parent class was insufficient. Thanks to @pijyoi for identifying this fix.
d215c43 to
e7e718a
Compare
|
Created https://bugreports.qt.io/browse/PYSIDE-1730 with @pijyoi 's minimum reproducible example, added a comment to this issue, think this is ready for merging now 👍🏻 |
|
The following is a better test of any eventual fix in PySide6 and reflects pyqtgraph's usage. ( It seems from the current discussion on https://bugreports.qt.io/browse/PYSIDE-1730 that a fixed version might still yield from PySide6 import QtCore
class Q(QtCore.QObject):
signal = QtCore.Signal()
class M:
def signal(self):
# default implementation
print("M::signal")
class C(M, Q):
pass
class D(C):
def signal(self):
# overridden implementation
print("D::signal")
c = C()
print(getattr(c.__class__, 'signal'))
print(c.signal)
d = D()
print(getattr(d.__class__, 'signal'))
print(d.signal)
c.signal() # expect M::signal
d.signal() # expect D::signal |
This fixes an issue that came up in PySide6 6.2.2 where calls to
GraphicsObject.parentChangedwere passed toQGraphicsObject.parentChangedinstead ofGraphicsItem.parentChangedAfter looking a bit more, the issue seems to only occur when there is a conflict between a method and signal, but when both inherited objects have the same method name, the correct one is used... and there does not appear to be any other conflicts with respect to signal names and method names.