Use add-function on QCoreApplication and QApplication constructors.
This was needed after a fix in the shiboken generator regarding the tp_init initialization.
This commit is contained in:
parent
3669f32af8
commit
a5249a70e1
4 changed files with 24 additions and 51 deletions
|
|
@ -2,43 +2,23 @@
|
||||||
static int QCoreApplicationArgCount;
|
static int QCoreApplicationArgCount;
|
||||||
static char** QCoreApplicationArgValues;
|
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()) {
|
if (QCoreApplication::instance()) {
|
||||||
PyErr_SetString(PyExc_RuntimeError, "A QCoreApplication instance already exists.");
|
PyErr_SetString(PyExc_RuntimeError, "A QCoreApplication instance already exists.");
|
||||||
return -1;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
int numArgs = PyTuple_GET_SIZE(args);
|
int numArgs = PyTuple_GET_SIZE(args);
|
||||||
if (numArgs != 1) {
|
if (numArgs != 1
|
||||||
|
|| !Shiboken::sequenceToArgcArgv(PyTuple_GET_ITEM(args, 0), &QCoreApplicationArgCount, &QCoreApplicationArgValues, "PySideApp")) {
|
||||||
PyErr_BadArgument();
|
PyErr_BadArgument();
|
||||||
return -1;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!Shiboken::sequenceToArgcArgv(PyTuple_GET_ITEM(args, 0), &QCoreApplicationArgCount, &QCoreApplicationArgValues, "PySideApp")) {
|
*cptr = new QCoreApplicationWrapper(QCoreApplicationArgCount, QCoreApplicationArgValues);
|
||||||
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();
|
|
||||||
|
|
||||||
|
Shiboken::Object::releaseOwnership(reinterpret_cast<SbkObject*>(self));
|
||||||
PySide::registerCleanupFunction(&PySide::destroyQCoreApplication);
|
PySide::registerCleanupFunction(&PySide::destroyQCoreApplication);
|
||||||
Py_INCREF(self);
|
Py_INCREF(self);
|
||||||
return 1;
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -2302,6 +2302,11 @@
|
||||||
in a more convenient form by the :meth:`~QCoreApplication.arguments()`
|
in a more convenient form by the :meth:`~QCoreApplication.arguments()`
|
||||||
method.
|
method.
|
||||||
</inject-documentation>
|
</inject-documentation>
|
||||||
|
<add-function signature="QCoreApplication(PySequence)">
|
||||||
|
<inject-code>
|
||||||
|
QCoreApplication_constructor(%PYSELF, args, &%0);
|
||||||
|
</inject-code>
|
||||||
|
</add-function>
|
||||||
<!-- blocking functions -->
|
<!-- blocking functions -->
|
||||||
<modify-function signature="processEvents(QFlags<QEventLoop::ProcessEventsFlag>, int)" allow-thread="yes"/>
|
<modify-function signature="processEvents(QFlags<QEventLoop::ProcessEventsFlag>, int)" allow-thread="yes"/>
|
||||||
<modify-function signature="processEvents(QFlags<QEventLoop::ProcessEventsFlag>)" allow-thread="yes"/>
|
<modify-function signature="processEvents(QFlags<QEventLoop::ProcessEventsFlag>)" allow-thread="yes"/>
|
||||||
|
|
|
||||||
|
|
@ -5,38 +5,22 @@ static int QApplicationArgCount;
|
||||||
static char** QApplicationArgValues;
|
static char** QApplicationArgValues;
|
||||||
static const char QAPP_MACRO[] = "qApp";
|
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()) {
|
if (QApplication::instance()) {
|
||||||
PyErr_SetString(PyExc_RuntimeError, "A QApplication instance already exists.");
|
PyErr_SetString(PyExc_RuntimeError, "A QApplication instance already exists.");
|
||||||
return -1;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
int numArgs = PyTuple_GET_SIZE(args);
|
int numArgs = PyTuple_GET_SIZE(args);
|
||||||
if (numArgs != 1) {
|
if (numArgs != 1
|
||||||
|
|| !Shiboken::sequenceToArgcArgv(PyTuple_GET_ITEM(args, 0), &QApplicationArgCount, &QApplicationArgValues, "PySideApp")) {
|
||||||
PyErr_BadArgument();
|
PyErr_BadArgument();
|
||||||
return -1;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!Shiboken::sequenceToArgcArgv(PyTuple_GET_ITEM(args, 0), &QApplicationArgCount, &QApplicationArgValues, "PySideApp")) {
|
*cptr = new QApplicationWrapper(QApplicationArgCount, QApplicationArgValues);
|
||||||
PyErr_BadArgument();
|
Shiboken::Object::releaseOwnership(reinterpret_cast<SbkObject*>(self));
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
|
|
||||||
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();
|
|
||||||
|
|
||||||
// Verify if qApp is in main module
|
// Verify if qApp is in main module
|
||||||
PyObject* globalsDict = PyEval_GetGlobals();
|
PyObject* globalsDict = PyEval_GetGlobals();
|
||||||
|
|
@ -49,5 +33,4 @@ int Sbk_QApplication_Init(PyObject* self, PyObject* args, PyObject*)
|
||||||
PyObject_SetAttrString(moduleQtGui, QAPP_MACRO, self);
|
PyObject_SetAttrString(moduleQtGui, QAPP_MACRO, self);
|
||||||
PySide::registerCleanupFunction(&PySide::destroyQCoreApplication);
|
PySide::registerCleanupFunction(&PySide::destroyQCoreApplication);
|
||||||
Py_INCREF(self);
|
Py_INCREF(self);
|
||||||
return 1;
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -5286,6 +5286,11 @@
|
||||||
<include file-name="QStyle" location="global"/>
|
<include file-name="QStyle" location="global"/>
|
||||||
</extra-includes>
|
</extra-includes>
|
||||||
<modify-function signature="QApplication(int&,char**)" access="private" />
|
<modify-function signature="QApplication(int&,char**)" access="private" />
|
||||||
|
<add-function signature="QApplication(PySequence)">
|
||||||
|
<inject-code>
|
||||||
|
QApplication_constructor(%PYSELF, args, &%0);
|
||||||
|
</inject-code>
|
||||||
|
</add-function>
|
||||||
<modify-function signature="exec()" rename="exec_" allow-thread="yes"/>
|
<modify-function signature="exec()" rename="exec_" allow-thread="yes"/>
|
||||||
<inject-code class="native" file="glue/qapplication_init.cpp" position="beginning" />
|
<inject-code class="native" file="glue/qapplication_init.cpp" position="beginning" />
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue