<div dir="ltr"><div>Hi Phil,</div><div><br></div><div>A PyQtGraph contributor ran into a PyQt5 issue involving opengl context.versionFunctions().</div><div><br></div><div>From what they can tell, the version only manifests itself for QOpenGLWidget used as a viewport to QGraphicsView.  If two (or more) QGraphicsItem separately store the result of versionFunctions(), all except one of the returned versionFunctions() instances will get deleted.<br></div><div><br></div><div>The behavior is as expected on PyQt6.</div><div><br></div><div>Here is a script to reproduce the issue:</div><div><br></div><div>from PyQt5 import QtCore, QtGui, QtWidgets, sip<br># from PyQt6 import QtCore, QtGui, QtWidgets, sip<br><br>if QtCore.PYQT_VERSION < 0x60000:<br>    QtOpenGLWidgets = QtWidgets<br>else:<br>    from PyQt6 import QtOpenGLWidgets, QtOpenGL<br><br>class MyItem(QtWidgets.QGraphicsRectItem):<br>    def __init__(self, *args, **kwargs):<br>        super().__init__(*args, **kwargs)<br>        self.context = None<br>        self.glfn = None<br><br>    def paint(self, painter, option, widget):<br>        context = widget.context()<br>        if context is not self.context:<br>            self.context = context<br>            if QtCore.PYQT_VERSION < 0x60000:<br>                profile = QtGui.QOpenGLVersionProfile()<br>                profile.setVersion(2, 0)<br>                self.glfn = context.versionFunctions(profile)<br>            else:<br>                profile = QtOpenGL.QOpenGLVersionProfile()<br>                profile.setVersion(2, 0)<br>                self.glfn = QtOpenGL.QOpenGLVersionFunctionsFactory.get(profile, context)<br><br>        # print(self.context, self.glfn)<br>        print(sip.isdeleted(self.glfn))<br>        color = QtCore.Qt.GlobalColor.red if sip.isdeleted(self.glfn) else QtCore.Qt.GlobalColor.green<br>        self.setBrush(QtGui.QBrush(color))<br>        super().paint(painter, option, widget)<br><br>app = QtWidgets.QApplication([])<br>gview = QtWidgets.QGraphicsView()<br>gview.resize(400, 400)<br>scene = QtWidgets.QGraphicsScene()<br>gview.setScene(scene)<br>viewport = QtOpenGLWidgets.QOpenGLWidget()<br>gview.setViewport(viewport)<br><br>rect1 = MyItem(0, 0, 100, 100)<br>scene.addItem(rect1)<br>rect2 = MyItem(0, -100, 100, 100)<br>scene.addItem(rect2)<br><br>gview.show()<br>app.exec()</div><div><br></div><div>The output on PyQt6 when running is:</div><div><br></div><div style="margin-left:40px">False</div><div style="margin-left:40px">False</div><div style="margin-left:40px">False</div><div style="margin-left:40px">False</div><div style="margin-left:40px">False</div><div style="margin-left:40px">False</div><div><br></div><div>The output on PyQt5 when running is:</div><div><br></div><div style="margin-left:40px">False<br>False<br>True<br>False<br>True<br>False</div><div><br></div><div>The resulting image is different to highlight the issue as well.</div><div><br></div><div>Let me know if there is additional information I can provide.</div><div><br></div><div>Thanks,</div><div>Ogi<br></div><div><div><div><br></div><div><br></div></div></div></div>