Re: [PyQt] APPCrash on exit, Qt4 MainWindow

2013-07-03 Thread Phil Thompson
On Tue, 2 Jul 2013 07:52:08 -0500, Erik egu...@gmail.com wrote:
 Python 2.7.4x32, Qt 4.8.4 (4.10.2-py27)x32 on Windows 7 64-bit OS PC's
 (multiple machines)
 
 I'm having a reproducible APPCRASH (in QtGUI4.dll) on exit of any
 application I write that uses a QMainWindow and a menuBar, if the window
 contains  10 other widgets.
 If I remove widgets down below the threshold (10), app closes normally.
 Whether I write it by hand or in QTDesigner, but if I include a menubar,
 blank or otherwise, App does not close properly in Windows resulting in
a
 'close program' Windows dialog.
 
 This happens on all 3 of my Windows 7 boxes here, but works fine in a
 instance of Windows XP on an older machine. (Same PyQt/Python versions)
 
 An example with code would be I create a QMainWindow in QT Designer, put
12
 widgets of any combination on it. (In this example I added a menu bar in
my
 code, but works the same (crash) if I add it in QTDesigner.
 
 
 import sys
 from PyQt4 import QtGui
 import ui_mainwindow as UIMW
 
 class MainWindow(QtGui.QMainWindow, UIMW.Ui_MainWindow):
 
 def __init__(self):
 super(MainWindow, self).__init__()
 self.setupUi(self)
 
 # MenuBar testing
 self.menubar = self.menuBar()
 menu = self.menubar.addMenu(Test)
 
 app = QtGui.QApplication(sys.argv)
 window = MainWindow()
 window.show()
 sys.exit(app.exec_())
 
 As long as my Ui_MainWindow has  10 widgets + menuBar, I get:
   Problem Event Name:APPCRASH
   Application Name:python.exe
   Application Version:0.0.0.0
   Application Timestamp:51606175
   Fault Module Name:QtGui4.dll
   Fault Module Version:4.8.4.0
 
 About 10% of the time, the first time I run the app, it will not crash
 until I run it again, click on some widgets, etc, and then exit.

Try experimenting with sip.setdestroyonexit().

Phil
___
PyQt mailing listPyQt@riverbankcomputing.com
http://www.riverbankcomputing.com/mailman/listinfo/pyqt


Re: [PyQt] APPCrash on exit, Qt4 MainWindow

2013-07-03 Thread egus
Thanks for the direction Phil.

I added sip.setdestroyonexit(False) to__init__ in my MainWindow class and
that appears to have negated the crashing on the two apps I tried it on.
Simply commenting that command out again caused the same apps to crash after
adding it.  So it's definitely the right direction.

My limited knowledge of sip, do I risk any memory leaks or other unexpected
behavior by bypassing the c++ destructor call this way? Are there any
cleanup methods/calls I should add when setting setdestroyonexit to False?

Thanks,
-egus




--
View this message in context: 
http://python.6.x6.nabble.com/APPCrash-on-exit-Qt4-MainWindow-tp5023351p5023518.html
Sent from the PyQt mailing list archive at Nabble.com.
___
PyQt mailing listPyQt@riverbankcomputing.com
http://www.riverbankcomputing.com/mailman/listinfo/pyqt


Re: [PyQt] APPCrash on exit, Qt4 MainWindow

2013-07-03 Thread Phil Thompson
On Wed, 3 Jul 2013 06:58:56 -0700 (PDT), egus egu...@gmail.com wrote:
 Thanks for the direction Phil.
 
 I added sip.setdestroyonexit(False) to__init__ in my MainWindow class
and
 that appears to have negated the crashing on the two apps I tried it on.
 Simply commenting that command out again caused the same apps to crash
 after
 adding it.  So it's definitely the right direction.
 
 My limited knowledge of sip, do I risk any memory leaks or other
unexpected
 behavior by bypassing the c++ destructor call this way? Are there any
 cleanup methods/calls I should add when setting setdestroyonexit to
False?

It depends on what your application does after the interpreter exits. If
it's just a Python script (ie. not embedded in a larger application) then
the process is about to terminate anyway. This is the default behaviour of
PyQt5.

Phil
___
PyQt mailing listPyQt@riverbankcomputing.com
http://www.riverbankcomputing.com/mailman/listinfo/pyqt