On Tue, Dec 21, 2010 at 7:12 PM, Hugo Parente Lima <[email protected]> wrote: > On Tuesday 21 December 2010 13:56:10 Vladimir Rutsky wrote: >> Hello, >> >> What is the "policy of crashing" for application that use PySide? >> Consider example: >> >> import sys >> from PySide import QtCore, QtGui >> >> # Forgot to initialize QApplication. >> # app = QtGui.QApplication(sys.argv) >> try: >> win = QtGui.QWidget() >> finally: >> print "done" >> >> Last string (print "done") will not be reached because running >> "QtGui.QWidget()" without initialized QApplication prints >> >> > QWidget: Must construct a QApplication before a QPaintDevice >> >> and exits python process with error code 1. > > This assertion is inside Qt code and if you construct a application this way > it's broken by design and shouldn't work at all, so there's not much > difference > in throwing an exception and let Qt finish the process in your use case.
This is just simple example. Thomas Perl posted better example when Qt exits when DISPLAY environment variable is incorrect. >> May be such exceptional situations inside Qt should be treated as >> exceptions in Python? > > List them, so we can think how to proceed. Currently I encountered cases when incorrect use signals/slots, e.g. accidentally emit signal with incorrect signature (see http://bugs.openbossa.org/show_bug.cgi?id=563), or connect signal to function that is not a slot. This last two examples is more like PySide bugs, that will be fixed in some way, but other cases like provided by Thomas should exist, I'm just not very familiar with Qt to give more examples right now. -- Vladimir Rutsky _______________________________________________ PySide mailing list [email protected] http://lists.openbossa.org/listinfo/pyside
