summaryrefslogtreecommitdiffstats
path: root/PySide
diff options
context:
space:
mode:
Diffstat (limited to 'PySide')
-rw-r--r--PySide/QtCore/glue/qcoreapplication_init.cpp33
-rw-r--r--PySide/QtCore/typesystem_core.xml15
-rw-r--r--PySide/QtGui/glue/qapplication_init.cpp32
-rw-r--r--PySide/QtGui/typesystem_gui_common.xml2
4 files changed, 59 insertions, 23 deletions
diff --git a/PySide/QtCore/glue/qcoreapplication_init.cpp b/PySide/QtCore/glue/qcoreapplication_init.cpp
index 5fcd79a3..7601dbd1 100644
--- a/PySide/QtCore/glue/qcoreapplication_init.cpp
+++ b/PySide/QtCore/glue/qcoreapplication_init.cpp
@@ -1,21 +1,30 @@
// Global variables used to store argc and argv values
static int QCoreApplicationArgCount;
static char** QCoreApplicationArgValues;
+static bool leavingPython = false;
/**
* Called at QtCore module exit
*/
-void DeleteQCoreApplicationAtExit() {
- if (QCoreApplication::instance()) {
- BindingManager::instance().invalidateWrapper(QCoreApplication::instance());
- QCoreApplication::instance()->deleteLater();
- for (int i = 0; i < QCoreApplicationArgCount; ++i)
- delete[] QCoreApplicationArgValues[i];
+void DeleteQCoreApplicationAtExit()
+{
+ leavingPython = true;
+ QCoreApplication *cpp = QCoreApplication::instance();
+ if (cpp) {
+ Shiboken::BindingManager &bmngr = Shiboken::BindingManager::instance();
+ PyObject* pySelf = bmngr.retrieveWrapper(cpp);
+ if (pySelf)
+ bmngr.invalidateWrapper(pySelf);
+ cpp->deleteLater();
}
}
int SbkQCoreApplication_Init(PyObject* self, PyObject* args, PyObject*)
{
+ if (Shiboken::isUserType(self) && !Shiboken::canCallConstructor(self->ob_type, Shiboken::SbkType<QApplication >()))
+ return -1;
+
+
if (QCoreApplication::instance()) {
PyErr_SetString(PyExc_RuntimeError, "A QCoreApplication instance already exists.");
return -1;
@@ -32,14 +41,20 @@ int SbkQCoreApplication_Init(PyObject* self, PyObject* args, PyObject*)
return -1;
}
- void* cptr = new QCoreApplication(QCoreApplicationArgCount, QCoreApplicationArgValues);
+ QCoreApplicationWrapper* cptr = new QCoreApplicationWrapper(QCoreApplicationArgCount, QCoreApplicationArgValues);
Shiboken::setCppPointer(reinterpret_cast<SbkBaseWrapper*>(self),
Shiboken::SbkType<QCoreApplication>(),
cptr);
+
SbkBaseWrapper_setValidCppObject(self, 1);
- Shiboken::BindingManager::instance().registerWrapper(reinterpret_cast<SbkBaseWrapper*>(self), cptr);
+ SbkBaseWrapper *sbkSelf = reinterpret_cast<SbkBaseWrapper*>(self);
+ sbkSelf->containsCppWrapper = 1;
+ sbkSelf->hasOwnership = 0;
+ Shiboken::BindingManager::instance().registerWrapper(sbkSelf, cptr);
+ PySide::signalUpdateSource(self);
+ cptr->metaObject();
- Py_INCREF(self);
Py_AtExit(DeleteQCoreApplicationAtExit);
+ Py_INCREF(self);
return 1;
}
diff --git a/PySide/QtCore/typesystem_core.xml b/PySide/QtCore/typesystem_core.xml
index 5355bf88..26991286 100644
--- a/PySide/QtCore/typesystem_core.xml
+++ b/PySide/QtCore/typesystem_core.xml
@@ -1762,6 +1762,7 @@
</modify-function>
</object-type>
<object-type name="QSignalMapper" />
+
<object-type name="QCoreApplication">
<extra-includes>
<include file-name="QStringList" location="global"/>
@@ -1786,16 +1787,26 @@
<modify-function signature="sendEvent(QObject*, QEvent*)" allow-thread="yes"/>
<modify-function signature="sendPostedEvents(QObject*, int)" allow-thread="yes"/>
<modify-function signature="sendPostedEvents()" allow-thread="yes"/>
+ <modify-function signature="instance()">
+ <modify-argument index="return">
+ <define-ownership owner="c++"/>
+ </modify-argument>
+ </modify-function>
<modify-function signature="exec()" rename="exec_" allow-thread="yes"/>
<modify-function signature="argv()" remove="all"/>
<!-- Obsolete -->
<modify-function signature="argc()" remove="all"/>
<!-- Obsolete -->
- <modify-function signature="notify(QObject*,QEvent*)" allow-thread="yes">
+ <modify-function signature="notify(QObject*,QEvent*)">
+ <inject-code class="shell" position="beginning">
+ Shiboken::ThreadStateSaver threadStateSaver;
+ if (!leavingPython)
+ threadStateSaver.save();
+ </inject-code>
<modify-argument index="2" invalidate-after-use="yes"/>
</modify-function>
- <modify-function signature="QCoreApplication(int &amp;, char **)" remove="all"/>
+ <modify-function signature="QCoreApplication(int &amp;, char **)" access="private"/>
<inject-code class="native" file="glue/qcoreapplication_init.cpp" position="beginning" />
<modify-function signature="postEvent(QObject*,QEvent*)">
<modify-argument index="2">
diff --git a/PySide/QtGui/glue/qapplication_init.cpp b/PySide/QtGui/glue/qapplication_init.cpp
index da9e2dc7..afbd3046 100644
--- a/PySide/QtGui/glue/qapplication_init.cpp
+++ b/PySide/QtGui/glue/qapplication_init.cpp
@@ -3,18 +3,25 @@ extern PyObject* moduleQtGui;
static int QApplicationArgCount;
static char** QApplicationArgValues;
+static const char QAPP_MACRO[] = "qApp";
void DeleteQApplicationAtExit() {
- if (QApplication::instance()) {
- BindingManager::instance().invalidateWrapper(QApplication::instance());
- QApplication::instance()->deleteLater();
- for (int i = 0; i < QApplicationArgCount; ++i)
- delete[] QApplicationArgValues[i];
+ PySide::SignalManager::instance().clear();
+ QCoreApplication* cpp = QApplication::instance();
+ if (cpp) {
+ Shiboken::BindingManager &bmngr = Shiboken::BindingManager::instance();
+ PyObject* pySelf = bmngr.retrieveWrapper(cpp);
+ if (pySelf)
+ bmngr.invalidateWrapper(pySelf);
+ cpp->deleteLater();
}
}
int SbkQApplication_Init(PyObject* self, PyObject* args, PyObject*)
{
+ if (Shiboken::isUserType(self) && !Shiboken::canCallConstructor(self->ob_type, Shiboken::SbkType<QApplication >()))
+ return -1;
+
if (QApplication::instance()) {
PyErr_SetString(PyExc_RuntimeError, "A QApplication instance already exists.");
return -1;
@@ -31,25 +38,28 @@ int SbkQApplication_Init(PyObject* self, PyObject* args, PyObject*)
return -1;
}
- void* cptr = new QApplication(QApplicationArgCount, QApplicationArgValues);
+ QApplicationWrapper* cptr = new QApplicationWrapper(QApplicationArgCount, QApplicationArgValues);
Shiboken::setCppPointer(reinterpret_cast<SbkBaseWrapper*>(self),
Shiboken::SbkType<QApplication>(),
cptr);
SbkBaseWrapper_setValidCppObject(self, 1);
- Shiboken::BindingManager::instance().registerWrapper(reinterpret_cast<SbkBaseWrapper*>(self), cptr);
+ SbkBaseWrapper *sbkSelf = reinterpret_cast<SbkBaseWrapper*>(self);
+ sbkSelf->containsCppWrapper = 1;
+ sbkSelf->hasOwnership = 0;
+ Shiboken::BindingManager::instance().registerWrapper(sbkSelf, cptr);
+ PySide::signalUpdateSource(self);
+ cptr->metaObject();
// Verify if qApp is in main module
- const char QAPP_MACRO[] = "qApp";
PyObject* globalsDict = PyEval_GetGlobals();
if (globalsDict) {
PyObject* qAppObj = PyDict_GetItemString(globalsDict, QAPP_MACRO);
if (qAppObj)
PyDict_SetItemString(globalsDict, QAPP_MACRO, self);
}
- PyObject_SetAttrString(moduleQtGui, QAPP_MACRO, self);
- Py_INCREF(self);
+ PyObject_SetAttrString(moduleQtGui, QAPP_MACRO, self);
Py_AtExit(DeleteQApplicationAtExit);
-
+ Py_INCREF(self);
return 1;
}
diff --git a/PySide/QtGui/typesystem_gui_common.xml b/PySide/QtGui/typesystem_gui_common.xml
index 80122c29..b11ec9f6 100644
--- a/PySide/QtGui/typesystem_gui_common.xml
+++ b/PySide/QtGui/typesystem_gui_common.xml
@@ -4358,7 +4358,7 @@
<include file-name="QLocale" location="global"/>
<include file-name="QStyle" location="global"/>
</extra-includes>
- <modify-function signature="QApplication(int &amp;, char **)" remove="all" />
+ <modify-function signature="QApplication(int &amp;, char **)" access="private" />
<modify-function signature="exec()" rename="exec_" allow-thread="yes"/>
<inject-code class="native" file="glue/qapplication_init.cpp" position="beginning" />