[Bug 561303] Re: PyQt4 applications crash at exit

Scott Kitterman ubuntu at kitterman.com
Fri Jun 22 01:25:31 UTC 2012


The full diff isn't needed and contains new features that aren't the
sort we generally accept for an SRU.  The relevant bit of the diff to
fix this problem is:

=== modified file 'sip/QtGui/qapplication.sip'
--- sip/QtGui/qapplication.sip  revid:james.westby at ubuntu.com-20100323222732-06b2oty73v82ag1o
+++ sip/QtGui/qapplication.sip  revid:cshorler at googlemail.com-20120520132153-3ifiwl7jly55pil0
@@ -1,4 +1,4 @@
-// qapplication.sip generated by MetaSIP on Wed Mar 17 18:29:25 2010
+// qapplication.sip generated by MetaSIP on Fri Apr 16 11:32:08 2010
 //
 // This file is part of the QtGui Python extension module.
 //
@@ -596,13 +596,17 @@
 %End
     virtual ~QApplication();
 %MethodCode
-        // Make sure all top level widgets are deleted before the QApplication.  This
-        // is a typical cause of crashes (or at least strange behaviour) when an
-        // application terminates.
+        // Make sure all top level widgets are not owned by Python and so won't be
+        // destroyed by the garbage collector after QApplication is destroyed.
         QWidgetList tlw = QApplication::topLevelWidgets();
         
         for (int i = 0; i < tlw.count(); ++i)
-            delete tlw.at(i);
+        {
+            PyObject *sw = sipGetPyObject(tlw.at(i), sipType_QWidget);
+        
+            if (sw)
+                sipTransferTo(sw, 0);
+        }
         
         // Handle all other QObject instances that we want to make sure are deleted
         // before the QApplication is deleted.

Please don't do the full version update.  Do a new one with this as a
patch.

-- 
You received this bug notification because you are a member of Kubuntu
Bugs, which is subscribed to python-qt4 in Ubuntu.
https://bugs.launchpad.net/bugs/561303

Title:
  PyQt4 applications crash at exit

To manage notifications about this bug go to:
https://bugs.launchpad.net/pylotro/+bug/561303/+subscriptions




More information about the kubuntu-bugs mailing list