Details
Description
A standard pattern for initializing QApplication in libraries is to use QApplication.instance() and fall back to explicitly instantiating QApplication() if that returns None. See here for an example from matplotlib.
When one calls QApplication.instance() without having first created a QApplication, this appears to have the side effect of setting all staticMetaObject attributes to None.
from PySide2 import QtCore, QtWidgets print(repr(QtCore.QObject.staticMetaObject)) app = QtWidgets.QApplication.instance() print(repr(QtCore.QObject.staticMetaObject)) if app is None: app = QtWidgets.QApplication([]) print(repr(QtCore.QObject.staticMetaObject))
I get a result that looks like this:
<PySide2.QtCore.QMetaObject object at 0x10e5c72c8> None None
When it should look like this:
<PySide2.QtCore.QMetaObject object at 0x10e5c72c8> <PySide2.QtCore.QMetaObject object at 0x10e5c72c8> <PySide2.QtCore.QMetaObject object at 0x10e5c72c8>
Checking for an existing QApplication with QApplication.startingUp() first appears to work OK, but I can't fix all of the third-party libraries to change to that pattern. PyQt4, PyQt5, PySide 1 all seem to be okay with the above pattern.
Attachments
Issue Links
- relates to
-
PYSIDE-1126 Segfault when QApplication exists before "import PySide2.QtCore"
- Closed
For Gerrit Dashboard: PYSIDE-1093 | ||||||
---|---|---|---|---|---|---|
# | Subject | Branch | Project | Status | CR | V |
275652,3 | Fix bad shutdown effect on QApplication.instance() | 5.13 | pyside/pyside-setup | Status: MERGED | +2 | 0 |