diff options
Diffstat (limited to 'sources/pyside2/PySide2/QtCore')
-rw-r--r-- | sources/pyside2/PySide2/QtCore/glue/qcoreapplication_init.cpp | 31 | ||||
-rw-r--r-- | sources/pyside2/PySide2/QtCore/typesystem_core_common.xml | 21 |
2 files changed, 20 insertions, 32 deletions
diff --git a/sources/pyside2/PySide2/QtCore/glue/qcoreapplication_init.cpp b/sources/pyside2/PySide2/QtCore/glue/qcoreapplication_init.cpp index c48b4ffa0..b2dfae38f 100644 --- a/sources/pyside2/PySide2/QtCore/glue/qcoreapplication_init.cpp +++ b/sources/pyside2/PySide2/QtCore/glue/qcoreapplication_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,27 +37,14 @@ ** ****************************************************************************/ -// Global variables used to store argc and argv values -static int QCoreApplicationArgCount; -static char** QCoreApplicationArgValues; - -void QCoreApplication_constructor(PyObject* self, PyObject* args, QCoreApplicationWrapper** cptr) +static void QCoreApplicationConstructor(PyObject *self, PyObject *pyargv, QCoreApplicationWrapper **cptr) { - if (QCoreApplication::instance()) { - PyErr_SetString(PyExc_RuntimeError, "A QCoreApplication instance already exists."); - return; - } - - int numArgs = PyTuple_GET_SIZE(args); - if (numArgs != 1 - || !Shiboken::sequenceToArgcArgv(PyTuple_GET_ITEM(args, 0), &QCoreApplicationArgCount, &QCoreApplicationArgValues, "PySideApp")) { - PyErr_BadArgument(); - return; + static int argc; + static char **argv; + PyObject *stringlist = PyTuple_GET_ITEM(pyargv, 0); + if (Shiboken::listToArgcArgv(stringlist, &argc, &argv, "PySideApp")) { + *cptr = new QCoreApplicationWrapper(argc, argv); + Shiboken::Object::releaseOwnership(reinterpret_cast<SbkObject*>(self)); + PySide::registerCleanupFunction(&PySide::destroyQCoreApplication); } - - *cptr = new QCoreApplicationWrapper(QCoreApplicationArgCount, QCoreApplicationArgValues, QT_VERSION); - - Shiboken::Object::releaseOwnership(reinterpret_cast<SbkObject*>(self)); - PySide::registerCleanupFunction(&PySide::destroyQCoreApplication); - Py_INCREF(self); } diff --git a/sources/pyside2/PySide2/QtCore/typesystem_core_common.xml b/sources/pyside2/PySide2/QtCore/typesystem_core_common.xml index bb0986f10..2b441eba0 100644 --- a/sources/pyside2/PySide2/QtCore/typesystem_core_common.xml +++ b/sources/pyside2/PySide2/QtCore/typesystem_core_common.xml @@ -3262,9 +3262,9 @@ in a more convenient form by the :meth:`~QCoreApplication.arguments()` method. </inject-documentation> - <add-function signature="QCoreApplication(PySequence)"> + <add-function signature="QCoreApplication(QStringList)"> <inject-code> - QCoreApplication_constructor(%PYSELF, args, &%0); + QCoreApplicationConstructor(%PYSELF, args, &%0); </inject-code> </add-function> <!-- blocking functions --> @@ -3275,23 +3275,24 @@ <modify-function signature="sendPostedEvents(QObject*, int)" allow-thread="yes"/> <modify-function signature="instance()"> <inject-code class="target"> - QCoreApplication* app = QCoreApplication::instance(); - PyObject* pyApp = Py_None; + QCoreApplication *app = QCoreApplication::instance(); + PyObject *pyApp = Py_None; if (app) { - pyApp = reinterpret_cast<PyObject*>(Shiboken::BindingManager::instance().retrieveWrapper(app)); + pyApp = reinterpret_cast<PyObject*>( + Shiboken::BindingManager::instance().retrieveWrapper(app)); if (!pyApp) - pyApp = %CONVERTTOPYTHON[QCoreApplication*](app); // this will keep app live after python exit (extra ref) + pyApp = %CONVERTTOPYTHON[QCoreApplication*](app); + // this will keep app live after python exit (extra ref) } + // PYSIDE-571: make sure that we return the singleton "None" + if (pyApp == Py_None) + Py_DECREF(MakeSingletonQAppWrapper(0)); // here qApp and instance() diverge %PYARG_0 = pyApp; Py_XINCREF(%PYARG_0); </inject-code> </modify-function> <modify-function signature="exec()" rename="exec_" allow-thread="yes"/> - <!-- ### Obsolete - <modify-function signature="argc()" remove="all"/> - <modify-function signature="argv()" remove="all"/> - --> <modify-function signature="notify(QObject*,QEvent*)" allow-thread="yes"> <modify-argument index="2" invalidate-after-use="yes"/> </modify-function> |