summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorHugo Parente Lima <hugo.pl@gmail.com>2011-05-10 18:11:55 -0300
committerHugo Parente Lima <hugo.pl@gmail.com>2011-05-11 11:13:13 -0300
commita5249a70e13891884ed62bc47558897377a4b800 (patch)
tree77e0de2b734ade63ad5da62bfd749073d2a6bcad
parent3669f32af8e6a39ba9add8d9e355639110bb9f1e (diff)
downloadpyside-a5249a70e13891884ed62bc47558897377a4b800.tar.gz
pyside-a5249a70e13891884ed62bc47558897377a4b800.tar.xz
pyside-a5249a70e13891884ed62bc47558897377a4b800.zip
Use add-function on QCoreApplication and QApplication constructors.
This was needed after a fix in the shiboken generator regarding the tp_init initialization.
-rw-r--r--PySide/QtCore/glue/qcoreapplication_init.cpp34
-rw-r--r--PySide/QtCore/typesystem_core.xml5
-rw-r--r--PySide/QtGui/glue/qapplication_init.cpp31
-rw-r--r--PySide/QtGui/typesystem_gui_common.xml5
4 files changed, 24 insertions, 51 deletions
diff --git a/PySide/QtCore/glue/qcoreapplication_init.cpp b/PySide/QtCore/glue/qcoreapplication_init.cpp
index 15e3e11..c92f03e 100644
--- a/PySide/QtCore/glue/qcoreapplication_init.cpp
+++ b/PySide/QtCore/glue/qcoreapplication_init.cpp
@@ -2,43 +2,23 @@
static int QCoreApplicationArgCount;
static char** QCoreApplicationArgValues;
-int Sbk_QCoreApplication_Init(PyObject* self, PyObject* args, PyObject*)
+void QCoreApplication_constructor(PyObject* self, PyObject* args, QCoreApplicationWrapper** cptr)
{
- if (Shiboken::Object::isUserType(self) && !Shiboken::ObjectType::canCallConstructor(self->ob_type, Shiboken::SbkType<QCoreApplication >()))
- return -1;
-
-
if (QCoreApplication::instance()) {
PyErr_SetString(PyExc_RuntimeError, "A QCoreApplication instance already exists.");
- return -1;
+ return;
}
int numArgs = PyTuple_GET_SIZE(args);
- if (numArgs != 1) {
+ if (numArgs != 1
+ || !Shiboken::sequenceToArgcArgv(PyTuple_GET_ITEM(args, 0), &QCoreApplicationArgCount, &QCoreApplicationArgValues, "PySideApp")) {
PyErr_BadArgument();
- return -1;
+ return;
}
- if (!Shiboken::sequenceToArgcArgv(PyTuple_GET_ITEM(args, 0), &QCoreApplicationArgCount, &QCoreApplicationArgValues, "PySideApp")) {
- PyErr_BadArgument();
- return -1;
- }
-
- SbkObject* sbkSelf = reinterpret_cast<SbkObject*>(self);
- QCoreApplicationWrapper* cptr = new QCoreApplicationWrapper(QCoreApplicationArgCount, QCoreApplicationArgValues);
- Shiboken::Object::setCppPointer(sbkSelf,
- Shiboken::SbkType<QCoreApplication>(),
- cptr);
-
- Shiboken::Object::setValidCpp(sbkSelf, true);
- Shiboken::Object::setHasCppWrapper(sbkSelf, true);
- Shiboken::Object::releaseOwnership(sbkSelf);
-
- Shiboken::BindingManager::instance().registerWrapper(sbkSelf, cptr);
- PySide::Signal::updateSourceObject(self);
- cptr->metaObject();
+ *cptr = new QCoreApplicationWrapper(QCoreApplicationArgCount, QCoreApplicationArgValues);
+ Shiboken::Object::releaseOwnership(reinterpret_cast<SbkObject*>(self));
PySide::registerCleanupFunction(&PySide::destroyQCoreApplication);
Py_INCREF(self);
- return 1;
}
diff --git a/PySide/QtCore/typesystem_core.xml b/PySide/QtCore/typesystem_core.xml
index be7957e..fb7ec59 100644
--- a/PySide/QtCore/typesystem_core.xml
+++ b/PySide/QtCore/typesystem_core.xml
@@ -2302,6 +2302,11 @@
in a more convenient form by the :meth:`~QCoreApplication.arguments()`
method.
</inject-documentation>
+ <add-function signature="QCoreApplication(PySequence)">
+ <inject-code>
+ QCoreApplication_constructor(%PYSELF, args, &amp;%0);
+ </inject-code>
+ </add-function>
<!-- blocking functions -->
<modify-function signature="processEvents(QFlags&lt;QEventLoop::ProcessEventsFlag&gt;, int)" allow-thread="yes"/>
<modify-function signature="processEvents(QFlags&lt;QEventLoop::ProcessEventsFlag&gt;)" allow-thread="yes"/>
diff --git a/PySide/QtGui/glue/qapplication_init.cpp b/PySide/QtGui/glue/qapplication_init.cpp
index 581e4da..16c7fef 100644
--- a/PySide/QtGui/glue/qapplication_init.cpp
+++ b/PySide/QtGui/glue/qapplication_init.cpp
@@ -5,38 +5,22 @@ static int QApplicationArgCount;
static char** QApplicationArgValues;
static const char QAPP_MACRO[] = "qApp";
-int Sbk_QApplication_Init(PyObject* self, PyObject* args, PyObject*)
+void QApplication_constructor(PyObject* self, PyObject* args, QApplicationWrapper** cptr)
{
- if (Shiboken::Object::isUserType(self) && !Shiboken::ObjectType::canCallConstructor(self->ob_type, Shiboken::SbkType<QApplication>()))
- return -1;
-
if (QApplication::instance()) {
PyErr_SetString(PyExc_RuntimeError, "A QApplication instance already exists.");
- return -1;
+ return;
}
int numArgs = PyTuple_GET_SIZE(args);
- if (numArgs != 1) {
- PyErr_BadArgument();
- return -1;
- }
-
- if (!Shiboken::sequenceToArgcArgv(PyTuple_GET_ITEM(args, 0), &QApplicationArgCount, &QApplicationArgValues, "PySideApp")) {
+ if (numArgs != 1
+ || !Shiboken::sequenceToArgcArgv(PyTuple_GET_ITEM(args, 0), &QApplicationArgCount, &QApplicationArgValues, "PySideApp")) {
PyErr_BadArgument();
- return -1;
+ return;
}
- SbkObject* sbkSelf = reinterpret_cast<SbkObject*>(self);
- QApplicationWrapper* cptr = new QApplicationWrapper(QApplicationArgCount, QApplicationArgValues);
- Shiboken::Object::setCppPointer(sbkSelf,
- Shiboken::SbkType<QApplication>(),
- cptr);
- Shiboken::Object::setValidCpp(sbkSelf, true);
- Shiboken::Object::setHasCppWrapper(sbkSelf, true);
- Shiboken::Object::releaseOwnership(sbkSelf);
- Shiboken::BindingManager::instance().registerWrapper(sbkSelf, cptr);
- PySide::Signal::updateSourceObject(self);
- cptr->metaObject();
+ *cptr = new QApplicationWrapper(QApplicationArgCount, QApplicationArgValues);
+ Shiboken::Object::releaseOwnership(reinterpret_cast<SbkObject*>(self));
// Verify if qApp is in main module
PyObject* globalsDict = PyEval_GetGlobals();
@@ -49,5 +33,4 @@ int Sbk_QApplication_Init(PyObject* self, PyObject* args, PyObject*)
PyObject_SetAttrString(moduleQtGui, QAPP_MACRO, self);
PySide::registerCleanupFunction(&PySide::destroyQCoreApplication);
Py_INCREF(self);
- return 1;
}
diff --git a/PySide/QtGui/typesystem_gui_common.xml b/PySide/QtGui/typesystem_gui_common.xml
index 30c4add..a0089a0 100644
--- a/PySide/QtGui/typesystem_gui_common.xml
+++ b/PySide/QtGui/typesystem_gui_common.xml
@@ -5286,6 +5286,11 @@
<include file-name="QStyle" location="global"/>
</extra-includes>
<modify-function signature="QApplication(int&amp;,char**)" access="private" />
+ <add-function signature="QApplication(PySequence)">
+ <inject-code>
+ QApplication_constructor(%PYSELF, args, &amp;%0);
+ </inject-code>
+ </add-function>
<modify-function signature="exec()" rename="exec_" allow-thread="yes"/>
<inject-code class="native" file="glue/qapplication_init.cpp" position="beginning" />