From 11a6f688cb3aeee57c1bfd8627eceab3e3393315 Mon Sep 17 00:00:00 2001 From: Ian Thompson Date: Tue, 28 Mar 2017 18:19:28 -0400 Subject: [PATCH] Fix bug arising from PyQt4 where QtGui.qApp is not initialized to None For example, in this first case we have what looks like a QApplication object, but it is not really there and will cause problems later. $ python -c 'from PyQt4 import QtGui; print QtGui.qApp' $ python -c 'from PySide import QtGui; print QtGui.qApp' None Instead we can use QtGui.QApplication.instance(), which always works and is documented in PySide to return the same as QtGui.qApp anyway. --- engine.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/engine.py b/engine.py index c5cd506..9cfada9 100644 --- a/engine.py +++ b/engine.py @@ -65,7 +65,7 @@ def has_ui(self): # a QApplication has been created. if self._has_qt: from tank.platform.qt import QtGui - return QtGui.qApp is not None + return QtGui.QApplication.instance() is not None else: return False @@ -129,7 +129,7 @@ def execute_command(self, cmd_key, args): # start up our QApp now, if none is already running qt_application = None - if not QtGui.qApp: + if not QtGui.QApplication.instance(): qt_application = QtGui.QApplication([]) qt_application.setWindowIcon(QtGui.QIcon(self.icon_256)) self._initialize_dark_look_and_feel()