[PyQt] Crash in frozen PyQt5 app

2013-08-30 Thread Glenn Ramsey

Hi,

When running the following test app on OSX (10.8.4, PyQt 5.1 snapshot + Qt 
5.1.1)

https://github.com/pyinstaller/pyinstaller/blob/develop/tests/interactive/test_pyqt5_qml.py

I get a crash when it is frozen using PyInstaller but not when it is not frozen. 
The crash occurs in QQuickView::setSource(...)


A stack trace for a very similar test app is here http://pastebin.com/ZhqZFPxG

Inspecting it in the debugger shows that the cause of the crash is that 
QCoreApplication::instance() returns 0 and in the stack trace shows the abort 
caused by a Q_ASSERT that I put in to check that.


Any ideas about what could be happening here?

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


Re: [PyQt] Crash in frozen PyQt5 app

2013-08-30 Thread Phil Thompson
On Fri, 30 Aug 2013 15:13:29 +1200, Glenn Ramsey g...@componic.co.nz
wrote:
 Hi,
 
 When running the following test app on OSX (10.8.4, PyQt 5.1 snapshot +
Qt
 5.1.1)
 

https://github.com/pyinstaller/pyinstaller/blob/develop/tests/interactive/test_pyqt5_qml.py
 
 I get a crash when it is frozen using PyInstaller but not when it is not
 frozen. 
 The crash occurs in QQuickView::setSource(...)
 
 A stack trace for a very similar test app is here
 http://pastebin.com/ZhqZFPxG
 
 Inspecting it in the debugger shows that the cause of the crash is that 
 QCoreApplication::instance() returns 0 and in the stack trace shows the
 abort 
 caused by a Q_ASSERT that I put in to check that.
 
 Any ideas about what could be happening here?

No, but a comment on the use of global app in the code...

The effect of that is to impose some order on the garbage collection of
Python objects. When main() returns the local objects get garbage collected
in an arbitrary order. If that order is wrong as far as Qt is concerned
then you get undefined behaviour or a crash. Specifying app as a global
means that it will get garbage collected later. Personally I never use a
main() function and put the code at the module level under if __name__ ==
'__main__'. It should only be a few lines anyway.

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