pyqt4topyqt5 icon indicating copy to clipboard operation
pyqt4topyqt5 copied to clipboard

QGraphicsItem subclasses init refactoring bug

Open smidm opened this issue 3 years ago • 0 comments

It seems that all initializations of QGraphicsItem subclasses are refactored in this way:

class MyEllipse(QtGui.QGraphicsEllipseItem):
+class MyEllipse(QtWidgets.QGraphicsEllipseItem):
     def __init__(self, radius=5.0):
-        super(MyEllipse, self).__init__(-radius/2, -radius/2, radius, radius)
+        super(MyEllipse, self).__init__(-radius/2, -radius/2, radius)
+        if radius is not None: radius.addItem(self)

The last argument is assumed to be scene and the addition to the scene is moved to a separate line. This assumption is not always true, in the sample above, the arguments are x, y, width, height and the addition to the scene is done elsewhere.

Workaround

Review the automatic changes using git.

changes not commited yet:

git diff --no-color > diff.txt

already commited changes:

git log # find the commit with changes done by pyqt4topyqt5
git show <commit> --no-color > diff.txt

Find new lines with addItem text using regexp: ^\+.*addItem (e.g. with less diff.txt).

smidm avatar Feb 16 '22 05:02 smidm