diff options
Diffstat (limited to 'sources/pyside2/PySide2/QtWidgets/glue/qapplication_init.cpp')
-rw-r--r-- | sources/pyside2/PySide2/QtWidgets/glue/qapplication_init.cpp | 46 |
1 files changed, 8 insertions, 38 deletions
diff --git a/sources/pyside2/PySide2/QtWidgets/glue/qapplication_init.cpp b/sources/pyside2/PySide2/QtWidgets/glue/qapplication_init.cpp index 0de34d9c5..1419f5755 100644 --- a/sources/pyside2/PySide2/QtWidgets/glue/qapplication_init.cpp +++ b/sources/pyside2/PySide2/QtWidgets/glue/qapplication_init.cpp @@ -1,6 +1,6 @@ /**************************************************************************** ** -** Copyright (C) 2016 The Qt Company Ltd. +** Copyright (C) 2017 The Qt Company Ltd. ** Contact: https://www.qt.io/licensing/ ** ** This file is part of PySide2. @@ -37,44 +37,14 @@ ** ****************************************************************************/ -// Borrowed reference to QtWidgets module -extern PyObject* moduleQtWidgets; - -static int QApplicationArgCount; -static char** QApplicationArgValues; -static const char QAPP_MACRO[] = "qApp"; - -bool QApplicationConstructorStart(PyObject* argv) -{ - if (QApplication::instance()) { - PyErr_SetString(PyExc_RuntimeError, "A QApplication instance already exists."); - return false; - } - - return Shiboken::sequenceToArgcArgv(argv, &QApplicationArgCount, &QApplicationArgValues, "PySideApp"); -} - -void QApplicationConstructorEnd(PyObject* self) -{ - // Verify if qApp is in main module - PyObject* globalsDict = PyEval_GetGlobals(); - if (globalsDict) { - PyObject* qAppObj = PyDict_GetItemString(globalsDict, QAPP_MACRO); - if (qAppObj) - PyDict_SetItemString(globalsDict, QAPP_MACRO, self); - } - - PyObject_SetAttrString(moduleQtWidgets, QAPP_MACRO, self); - PySide::registerCleanupFunction(&PySide::destroyQCoreApplication); - Py_INCREF(self); -} - -static void QApplicationConstructor(PyObject* self, PyObject* argv, QApplicationWrapper** cptr) +static void QApplicationConstructor(PyObject *self, PyObject *pyargv, QApplicationWrapper **cptr) { - if (QApplicationConstructorStart(argv)) { - // XXX do we need to support the ApplicationFlags parameter, instead of 0? - *cptr = new QApplicationWrapper(QApplicationArgCount, QApplicationArgValues, 0); + static int argc; + static char **argv; + PyObject *stringlist = PyTuple_GET_ITEM(pyargv, 0); + if (Shiboken::listToArgcArgv(stringlist, &argc, &argv, "PySideApp")) { + *cptr = new QApplicationWrapper(argc, argv, 0); Shiboken::Object::releaseOwnership(reinterpret_cast<SbkObject*>(self)); - QApplicationConstructorEnd(self); + PySide::registerCleanupFunction(&PySide::destroyQCoreApplication); } } |