diff options
author | Renato Araujo Oliveira Filho <renato.filho@openbossa.org> | 2010-11-18 11:02:03 -0300 |
---|---|---|
committer | Renato Araujo Oliveira Filho <renato.filho@openbossa.org> | 2010-11-19 15:15:12 -0300 |
commit | 5e0550446c3546beb4a7076a80a7475b394567f4 (patch) | |
tree | 4709c72e275bdc1c54c914ccedfa11ec07af200e | |
parent | 098946263932e115bdbca17eb51c3a27848435e2 (diff) | |
download | pyside-5e0550446c3546beb4a7076a80a7475b394567f4.tar.gz pyside-5e0550446c3546beb4a7076a80a7475b394567f4.tar.xz pyside-5e0550446c3546beb4a7076a80a7475b394567f4.zip |
Updated to new shiboken API.
Reviewer: Hugo Parente Lima <hugo.pl@gmail.com>
Luciano Wolf <luciano.wolf@openbossa.org>
-rw-r--r-- | PySide/QtCore/typesystem_core.xml | 15 | ||||
-rw-r--r-- | PySide/QtGui/glue/qlayout_help_functions.h | 6 | ||||
-rw-r--r-- | PySide/QtGui/glue/qwidget_glue.h | 6 | ||||
-rw-r--r-- | PySide/QtGui/typesystem_gui_common.xml | 26 | ||||
-rw-r--r-- | PySide/QtUiTools/glue/uitools_loadui.h | 2 | ||||
-rw-r--r-- | PySide/QtWebKit/typesystem_webkit.xml | 2 | ||||
-rw-r--r-- | PySide/typesystem_templates.xml | 6 | ||||
-rw-r--r-- | libpyside/pyside.cpp | 4 | ||||
-rw-r--r-- | plugins/customwidget.cpp | 4 |
9 files changed, 34 insertions, 37 deletions
diff --git a/PySide/QtCore/typesystem_core.xml b/PySide/QtCore/typesystem_core.xml index b048bf0..83fd2ed 100644 --- a/PySide/QtCore/typesystem_core.xml +++ b/PySide/QtCore/typesystem_core.xml @@ -1129,7 +1129,7 @@ %PYARG_0 = %CONVERTTOPYTHON[%RETURN_TYPE](%CPPSELF.%FUNCTION_NAME()); </inject-code> <modify-argument index="return"> - <parent index="this" action="add"/> + <reference-count action="add"/> </modify-argument> </modify-function> <modify-function signature="deleteLater()"> @@ -1941,8 +1941,7 @@ %PYARG_2, %3) ); - // invalidate to avoid use of python object - Shiboken::BindingManager::instance().destroyWrapper((SbkObject*)pyTimer); + Shiboken::Wrapper::invalidate((SbkObject*)pyTimer); timer->setSingleShot(true); timer->connect(timer, SIGNAL(timeout()), timer, SLOT(deleteLater())); timer->start(%1); @@ -1952,7 +1951,7 @@ <inject-code class="target" position="beginning"> // %FUNCTION_NAME() - disable generation of c++ function call Shiboken::AutoDecRef emptyTuple(PyTuple_New(0)); - PyObject* pyTimer = Shiboken::SbkType<QTimer>()->tp_new(Shiboken::SbkType<QTimer>(), emptyTuple, 0); + PyObject *pyTimer = Shiboken::SbkType<QTimer>()->tp_new(Shiboken::SbkType<QTimer>(), emptyTuple, 0); Shiboken::SbkType<QTimer>()->tp_init(pyTimer, emptyTuple, 0); QTimer* timer = Converter<QTimer*>::toCpp(pyTimer); timer->setSingleShot(true); @@ -1980,7 +1979,7 @@ pyargs[1]) ); } - Shiboken::BindingManager::instance().destroyWrapper((SbkObject*)pyTimer); + Shiboken::Wrapper::invalidate((SbkObject*)pyTimer); timer->start(%1); </inject-code> </add-function> @@ -2568,7 +2567,7 @@ <inject-code class="target" position="beginning"> for(int counter = 0; counter < %CPPSELF.animationCount(); ++counter ) { PyObject* obj = %CONVERTTOPYTHON[QAbstractAnimation*](%CPPSELF.animationAt(counter)); - Shiboken::setParent(NULL, obj); + Shiboken::Wrapper::setParent(NULL, obj); Py_DECREF(obj); } %CPPSELF.clear(); @@ -2722,7 +2721,7 @@ %PYARG_0 = PySet_New(0); foreach(QAbstractState* abs_state, %CPPSELF.configuration()) { Shiboken::AutoDecRef obj(%CONVERTTOPYTHON[QAbstractState*](abs_state)); - Shiboken::setParent(self, obj); + Shiboken::Wrapper::setParent(self, obj); PySet_Add(%PYARG_0, obj); } </inject-code> @@ -2733,7 +2732,7 @@ %PYARG_0 = PyList_New(0); foreach(QAbstractAnimation* abs_anim, %CPPSELF.defaultAnimations()) { Shiboken::AutoDecRef obj(%CONVERTTOPYTHON[QAbstractAnimation*](abs_anim)); - Shiboken::setParent(self, obj); + Shiboken::Wrapper::setParent(self, obj); PyList_Append(%PYARG_0, obj); } </inject-code> diff --git a/PySide/QtGui/glue/qlayout_help_functions.h b/PySide/QtGui/glue/qlayout_help_functions.h index 452dbc1..8d899ea 100644 --- a/PySide/QtGui/glue/qlayout_help_functions.h +++ b/PySide/QtGui/glue/qlayout_help_functions.h @@ -22,7 +22,7 @@ inline void addLayoutOwnership(QLayout* layout, QWidget* widget) } else { Shiboken::AutoDecRef pyParent(Shiboken::Converter<QWidget*>::toPython(parent)); Shiboken::AutoDecRef pyChild(Shiboken::Converter<QWidget*>::toPython(widget)); - Shiboken::setParent(pyParent, pyChild); + Shiboken::Wrapper::setParent(pyParent, pyChild); } } @@ -48,7 +48,7 @@ inline void addLayoutOwnership(QLayout* layout, QLayout* other) Shiboken::AutoDecRef pyParent(Shiboken::Converter<QLayout*>::toPython(layout)); Shiboken::AutoDecRef pyChild(Shiboken::Converter<QLayout*>::toPython(other)); - Shiboken::setParent(pyParent, pyChild); + Shiboken::Wrapper::setParent(pyParent, pyChild); } @@ -65,7 +65,7 @@ inline void addLayoutOwnership(QLayout* layout, QLayoutItem* item) Shiboken::AutoDecRef pyParent(Shiboken::Converter<QLayout*>::toPython(layout)); Shiboken::AutoDecRef pyChild(Shiboken::Converter<QLayoutItem*>::toPython(item)); - Shiboken::setParent(pyParent, pyChild); + Shiboken::Wrapper::setParent(pyParent, pyChild); } #endif diff --git a/PySide/QtGui/glue/qwidget_glue.h b/PySide/QtGui/glue/qwidget_glue.h index d067d9f..33e8a7f 100644 --- a/PySide/QtGui/glue/qwidget_glue.h +++ b/PySide/QtGui/glue/qwidget_glue.h @@ -22,7 +22,7 @@ static inline void qwidgetReparentLayout(QWidget *parent, QLayout *layout) QWidget* pw = w->parentWidget(); if (pw != parent) { Shiboken::AutoDecRef pyChild(Shiboken::Converter<QWidget*>::toPython(w)); - Shiboken::setParent(pyParent, pyChild); + Shiboken::Wrapper::setParent(pyParent, pyChild); } } else { QLayout* l = item->layout(); @@ -32,7 +32,7 @@ static inline void qwidgetReparentLayout(QWidget *parent, QLayout *layout) } Shiboken::AutoDecRef pyChild(Shiboken::Converter<QLayout*>::toPython(layout)); - Shiboken::setParent(pyParent, pyChild); + Shiboken::Wrapper::setParent(pyParent, pyChild); //remove previous references Shiboken::keepReference(reinterpret_cast<SbkObject*>(pyChild.object()), qPrintable(retrieveObjectName(pyChild)), Py_None); } @@ -47,7 +47,7 @@ static inline void qwidgetSetLayout(QWidget *self, QLayout *layout) if (oldParent->isWidgetType()) { // remove old parent policy Shiboken::AutoDecRef pyLayout(Shiboken::Converter<QLayout*>::toPython(layout)); - Shiboken::setParent(Py_None, pyLayout); + Shiboken::Wrapper::setParent(Py_None, pyLayout); } else { PyErr_Format(PyExc_RuntimeError, "QWidget::setLayout: Attempting to set QLayout \"%s\" on %s \"%s\", when the QLayout already has a parent", qPrintable(layout->objectName()), self->metaObject()->className(), qPrintable(self->objectName())); diff --git a/PySide/QtGui/typesystem_gui_common.xml b/PySide/QtGui/typesystem_gui_common.xml index 04ad22a..ca7bc27 100644 --- a/PySide/QtGui/typesystem_gui_common.xml +++ b/PySide/QtGui/typesystem_gui_common.xml @@ -1621,7 +1621,7 @@ <reference-count action="add"/> </modify-argument> <inject-code> - BindingManager::instance().transferOwnershipToCpp(%PYARG_2); + Shiboken::Wrapper::releaseOwnership(%PYARG_2); </inject-code> </modify-function> <modify-function signature="setDefaultFactory(QItemEditorFactory *)"> @@ -1955,7 +1955,7 @@ <inject-code class="target" position="end"> Shiboken::AutoDecRef result(PyObject_CallMethod(%PYSELF, "connect", "OsO", %PYSELF, SIGNAL(activated()), %PYARG_3)); if (!result.isNull()) - Shiboken::setParent(%PYARG_2, %PYSELF); + Shiboken::Wrapper::setParent(%PYARG_2, %PYSELF); </inject-code> </add-function> </object-type> @@ -2018,7 +2018,7 @@ QStandardItem* _i = %CPPSELF->child(%1, %2); if (_i) { PyObject* _pyI = %CONVERTTOPYTHON[QStandardItem*](_i); - Shiboken::setParent(0, _pyI); + Shiboken::Wrapper::setParent(0, _pyI); } </inject-code> <modify-argument index="3"> @@ -2031,7 +2031,7 @@ QStandardItem* _i = %CPPSELF->child(%1); if (_i) { PyObject* _pyI = %CONVERTTOPYTHON[QStandardItem*](_i); - Shiboken::setParent(0, _pyI); + Shiboken::Wrapper::setParent(0, _pyI); } </inject-code> <modify-argument index="2"> @@ -2170,7 +2170,7 @@ QWidget *_widget = %CPPSELF.widget(%1); if (_widget) { Shiboken::AutoDecRef pyWidget(%CONVERTTOPYTHON[QWidget*](_widget)); - Shiboken::setParent(0, pyWidget); + Shiboken::Wrapper::setParent(0, pyWidget); } </inject-code> </modify-function> @@ -3328,7 +3328,7 @@ QStyle *appStyle = qApp->style(); if (appStyle == myStyle) { Shiboken::AutoDecRef pyApp(%CONVERTTOPYTHON[QApplication*](qApp)); - Shiboken::setParent(pyApp, %PYARG_0); + Shiboken::Wrapper::setParent(pyApp, %PYARG_0); Shiboken::Wrapper::releaseOwnership(%PYARG_0); } else { Shiboken::keepReference(reinterpret_cast<SbkObject*>(%PYSELF), "__style__", %PYARG_0); @@ -3586,7 +3586,7 @@ QWidget* tab = %CPPSELF.widget(%1); if (tab) { Shiboken::AutoDecRef pyWidget(%CONVERTTOPYTHON[QWidget*](tab)); - Shiboken::setParent(0, pyWidget); + Shiboken::Wrapper::setParent(0, pyWidget); %CPPSELF.%FUNCTION_NAME(%1); } </inject-code> @@ -3595,7 +3595,7 @@ <inject-code class="target" position="beginning"> for (int i=0; i < %CPPSELF.count(); i++) { Shiboken::AutoDecRef pyWidget(%CONVERTTOPYTHON[QWidget*](%CPPSELF.widget(i))); - Shiboken::setParent(0, pyWidget); + Shiboken::Wrapper::setParent(0, pyWidget); } %CPPSELF.%FUNCTION_NAME(); </inject-code> @@ -3853,7 +3853,7 @@ QStandardItem* _i = %CPPSELF->item(%1, %2); if (_i) { PyObject* _pyI = %CONVERTTOPYTHON[QStandardItem*](_i); - Shiboken::setParent(0, _pyI); + Shiboken::Wrapper::setParent(0, _pyI); } </inject-code> <modify-argument index="3"> @@ -3866,7 +3866,7 @@ QStandardItem* _i = %CPPSELF->item(%1); if (_i) { PyObject* _pyI = %CONVERTTOPYTHON[QStandardItem*](_i); - Shiboken::setParent(0, _pyI); + Shiboken::Wrapper::setParent(0, _pyI); } </inject-code> <modify-argument index="2"> @@ -3885,7 +3885,7 @@ QStandardItem* _i = %CPPSELF->verticalHeaderItem(%1); if (_i) { PyObject* _pyI = %CONVERTTOPYTHON[QStandardItem*](_i); - Shiboken::setParent(0, _pyI); + Shiboken::Wrapper::setParent(0, _pyI); } </inject-code> <modify-argument index="2"> @@ -3935,7 +3935,7 @@ QList<QStandardItem *> ri = %CPPSELF.takeRow(0); PyObject *pyResult = %CONVERTTOPYTHON[QList<QStandardItem * >](ri); - Shiboken::setParent(Py_None, pyResult); + Shiboken::Wrapper::setParent(Py_None, pyResult); Py_XDECREF(pyResult); } </inject-code> @@ -4554,7 +4554,7 @@ <!-- ownership control transfer to qApp --> <modify-function signature="setStyle(QStyle*)"> <inject-code class="target" position="end"> - Shiboken::setParent(%CONVERTTOPYTHON[QApplication*](qApp), %PYARG_1); + Shiboken::Wrapper::setParent(%CONVERTTOPYTHON[QApplication*](qApp), %PYARG_1); </inject-code> </modify-function> <modify-function signature="style()"> diff --git a/PySide/QtUiTools/glue/uitools_loadui.h b/PySide/QtUiTools/glue/uitools_loadui.h index 8f6df63..302c3e7 100644 --- a/PySide/QtUiTools/glue/uitools_loadui.h +++ b/PySide/QtUiTools/glue/uitools_loadui.h @@ -20,7 +20,7 @@ _populate_parent(PyObject* pyParent, QObject *parent) if (!has_attr) PyObject_SetAttrString(pyParent, qPrintable(name), pyChild); - Shiboken::setParent(pyParent, pyChild); + Shiboken::Wrapper::setParent(pyParent, pyChild); _populate_parent(pyChild, qobject_cast<QObject*>(child)); } } diff --git a/PySide/QtWebKit/typesystem_webkit.xml b/PySide/QtWebKit/typesystem_webkit.xml index b56a909..9ec7c75 100644 --- a/PySide/QtWebKit/typesystem_webkit.xml +++ b/PySide/QtWebKit/typesystem_webkit.xml @@ -41,7 +41,7 @@ <inject-code position="end"> SbkObject* _pyReturn = reinterpret_cast<SbkObject*>(%PYARG_0); if (!Shiboken::Wrapper::hasParentInfo(_pyReturn)) - Shiboken::setParent(%PYSELF, %PYARG_0); + Shiboken::Wrapper::setParent(%PYSELF, %PYARG_0); </inject-code> </modify-function> <modify-function signature="print(QPrinter*)const" rename="print_" /> diff --git a/PySide/typesystem_templates.xml b/PySide/typesystem_templates.xml index 968195f..6bc814d 100644 --- a/PySide/typesystem_templates.xml +++ b/PySide/typesystem_templates.xml @@ -23,9 +23,9 @@ $CHILD_TYPE* oldChild = %CPPSELF.$FUNCTION_GET_OLD(); if (oldChild) { Shiboken::AutoDecRef pyChild(%CONVERTTOPYTHON[$CHILD_TYPE*](oldChild)); - Shiboken::setParent(NULL, pyChild); + Shiboken::Wrapper::setParent(NULL, pyChild); } - Shiboken::setParent(%PYSELF, $PYARG); + Shiboken::Wrapper::setParent(%PYSELF, $PYARG); </template> <!-- Templates to fix bool* parameters --> @@ -184,7 +184,7 @@ <template name="set_qapp_parent_for_orphan"> SbkObject* _pySelf = reinterpret_cast<SbkObject*>(%PYARG_0); if (!Shiboken::Wrapper::hasParentInfo(_pySelf)) - Shiboken::setParent(%CONVERTTOPYTHON[QApplication*](qApp), %PYARG_0); + Shiboken::Wrapper::setParent(%CONVERTTOPYTHON[QApplication*](qApp), %PYARG_0); </template> <!-- templates for __reduce__ --> <template name="reduce_code"> diff --git a/libpyside/pyside.cpp b/libpyside/pyside.cpp index 7866fc6..803f41d 100644 --- a/libpyside/pyside.cpp +++ b/libpyside/pyside.cpp @@ -117,12 +117,10 @@ void destroyQCoreApplication() foreach (SbkObject* pyObj, bm.getAllPyObjects()) { if (pyObj != pyQApp && PyObject_TypeCheck(pyObj, pyQObjectType)) { if (Shiboken::Wrapper::hasOwnership(pyObj)) { - bm.destroyWrapper(pyObj); - delete static_cast<QObject*>(Shiboken::Wrapper::cppPointer(pyObj, Shiboken::SbkType<QObject*>())); + Shiboken::callCppDestructor<QObject*>(Shiboken::Wrapper::cppPointer(pyObj, Shiboken::SbkType<QObject*>())); } } } - app->flush(); delete app; } diff --git a/plugins/customwidget.cpp b/plugins/customwidget.cpp index 6165ebf..e9fc64e 100644 --- a/plugins/customwidget.cpp +++ b/plugins/customwidget.cpp @@ -117,9 +117,9 @@ QWidget* PyCustomWidget::createWidget(QWidget* parent) QWidget* widget = 0; if (result) { if (unkowParent) //if parent does not exists in python, transfer the ownership to cpp - Shiboken::BindingManager::instance().transferOwnershipToCpp(result); + Shiboken::Wrapper::releaseOwnership(result); else - Shiboken::setParent(pyParent, reinterpret_cast<PyObject*>(result)); + Shiboken::Wrapper::setParent(pyParent, reinterpret_cast<PyObject*>(result)); widget = reinterpret_cast<QWidget*>(Shiboken::Wrapper::cppPointer(result, result->ob_type)); } |