aboutsummaryrefslogtreecommitdiffstats
path: root/sources/pyside2/PySide2/QtCore
diff options
context:
space:
mode:
authorFriedemann Kleint <Friedemann.Kleint@qt.io>2017-10-27 14:20:36 +0200
committerFriedemann Kleint <Friedemann.Kleint@qt.io>2017-10-27 14:20:36 +0200
commit25f899e276c00b8d7f334819d6cd7927ed67093a (patch)
treed2a063aab76e0435eb862ca5d2b541a5e718f062 /sources/pyside2/PySide2/QtCore
parent4725008aeea407ae55cfd66de802dd9e06412efc (diff)
parente30e0c161b2b4d50484314bf006e9e5e8ff6b380 (diff)
Merge remote-tracking branch 'origin/5.6' into 5.9
Diffstat (limited to 'sources/pyside2/PySide2/QtCore')
-rw-r--r--sources/pyside2/PySide2/QtCore/glue/qcoreapplication_init.cpp31
-rw-r--r--sources/pyside2/PySide2/QtCore/typesystem_core_common.xml21
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 c48b4ffa..b2dfae38 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 bb0986f1..2b441eba 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, &amp;%0);
+ QCoreApplicationConstructor(%PYSELF, args, &amp;%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&lt;PyObject*&gt;(Shiboken::BindingManager::instance().retrieveWrapper(app));
+ pyApp = reinterpret_cast&lt;PyObject*&gt;(
+ 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>