[PySide] open/close QMdiArea subwindows
Joel B. Mohler
jmohler at gamry.com
Mon Feb 25 18:14:19 CET 2013
On 2/23/2013 4:55 AM, Stefan Champailler wrote:
> Well, I'm not sure but according to the Qmdiarea doc,
> addSubwindow does not take ownership of the window.
> So when the execution path leaves newkid(), w is deleted
> and then QMdiArea looses it as well...
> (but I just read the doc, didn't test)
I don't think that justifies the crash. If the w widget goes out of
scope then the widget should have never appeared (being entirely torn
down by python reference counting on its way out of scope). Either way,
I've reported it at https://bugreports.qt-project.org/browse/PYSIDE-144
because I don't think that my app-side python reference issues should
cause C level segfault crashes.
On 02/21/2013 11:45 PM, Joel B. Mohler wrote:
>> TL;DR; QMdiArea claims to take any QWidget in the addSubWindow method.
>> However, in PySide, this appears to work but it will almost certainly
>> segfault after many (or few) open/close cycles.
>> I get a segfault in both windows and linux on the following code. After
>> opening and closing the window created in "newkid" 4-50 times. I simply
>> start the program and press Ctrl+F5, Ctrl+W repeatedly activating the
>> QAction and using the platform specific close sub-window shortcut. The
>> nondescript newkid widget appears and disappears until on some open I
>> get a segfault.
>> #!/usr/bin/env python
>> from PySide import QtCore, QtGui
>> class MainWin(QtGui.QMainWindow):
>> def __init__(self, parent=None):
>> super(MainWin, self).__init__(parent)
>> self.myaction = QtGui.QAction("add win", self)
>> def newkid(self):
>> w = QtGui.QWidget()
>> w.setWindowTitle("hi there")
>> if __name__ == '__main__':
>> app = QtGui.QApplication()
>> w = MainWin()
>> Both systems are running PySide 1.1.2 and Qt 4.8.x.
>> Indeed, I've modified the example to make a QMdiSubWindow rather than a
>> QWidget and I have yet to have it crash for me after pounding on the F5
>> & W keys as described above. I think I have a fix then for the
>> immediate issue, but I guess this is a bug for the bug tracker as well
>> since the qmdiarea docs imply this should work. I think I'm with-in
>> bounds for the documentation at
>> http://qt-project.org/doc/qt-4.8/qmdiarea.html#addSubWindow .
>> (Side-note: this is one of the other things that went wrong in my
>> thread about "RuntimeError: Failed to connect signal" ... the bug hunt
>> is wide open I guess and expect I'll find other issues)
>> PySide mailing list
>> PySide at qt-project.org
More information about the PySide