diff options
| author | Friedemann Kleint <Friedemann.Kleint@qt.io> | 2020-02-24 10:01:52 +0100 |
|---|---|---|
| committer | Friedemann Kleint <Friedemann.Kleint@qt.io> | 2020-02-24 10:01:52 +0100 |
| commit | 491e85ef2bb7b39de39604b8e20f679c97a2981a (patch) | |
| tree | 15f84b1e68a03d8ff5f6fcaa33a17e56444c37c5 /sources/pyside2/libpyside/pyside.cpp | |
| parent | fa709e93b80ac7d92dbf6be6d5ce807b4e487e1d (diff) | |
| parent | d579912b31d7cfa7b0b216916fbbf3eb632a9d9d (diff) | |
Merge remote-tracking branch 'origin/5.14' into 5.15
Change-Id: I587b40f07da85d431d4fdb6f98259a9be0bb73e5
Diffstat (limited to 'sources/pyside2/libpyside/pyside.cpp')
| -rw-r--r-- | sources/pyside2/libpyside/pyside.cpp | 20 |
1 files changed, 19 insertions, 1 deletions
diff --git a/sources/pyside2/libpyside/pyside.cpp b/sources/pyside2/libpyside/pyside.cpp index eeb4de037..d22958398 100644 --- a/sources/pyside2/libpyside/pyside.cpp +++ b/sources/pyside2/libpyside/pyside.cpp @@ -94,6 +94,7 @@ void init(PyObject *module) MetaFunction::init(module); // Init signal manager, so it will register some meta types used by QVariant. SignalManager::instance(); + initQApp(); } static bool _setProperty(PyObject *qObj, PyObject *name, PyObject *value, bool *accept) @@ -214,7 +215,7 @@ void destroyQCoreApplication() delete app; Py_END_ALLOW_THREADS // PYSIDE-571: make sure to create a singleton deleted qApp. - MakeSingletonQAppWrapper(NULL); + Py_DECREF(MakeQAppWrapper(nullptr)); } std::size_t getSizeOfQObject(SbkObjectType *type) @@ -299,6 +300,23 @@ void initQObjectSubType(SbkObjectType *type, PyObject *args, PyObject * /* kwds initDynamicMetaObject(type, userData->mo.update(), userData->cppObjSize); } +void initQApp() +{ + /* + * qApp will not be initialized when embedding is active. + * That means that qApp exists already when PySide is initialized. + * We could solve that by creating a qApp variable, but in embedded + * mode, we also have the effect that the first assignment to qApp + * is persistent! Therefore, we can never be sure to have created + * qApp late enough to get the right type for the instance. + * + * I would appreciate very much if someone could explain or even fix + * this issue. It exists only when a pre-existing application exists. + */ + if (!qApp) + Py_DECREF(MakeQAppWrapper(nullptr)); +} + PyObject *getMetaDataFromQObject(QObject *cppSelf, PyObject *self, PyObject *name) { PyObject *attr = PyObject_GenericGetAttr(self, name); |
