From 16913eedcec8c71b129dfcb029e0eb0fc50bb2a1 Mon Sep 17 00:00:00 2001 From: Luciano Wolf Date: Wed, 17 Nov 2010 18:58:39 -0300 Subject: Fix setLayout method that was causing segfault when itemAt wasn't implemented. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Reviewer: Hugo Parente Renato Araújo --- PySide/QtGui/glue/qlayout_help_functions.h | 8 ++++++-- PySide/QtGui/glue/qwidget_glue.h | 22 ++++++++++++---------- PySide/QtGui/typesystem_gui_common.xml | 1 + 3 files changed, 19 insertions(+), 12 deletions(-) (limited to 'PySide/QtGui') diff --git a/PySide/QtGui/glue/qlayout_help_functions.h b/PySide/QtGui/glue/qlayout_help_functions.h index 0a6dd0eb0..452dbc181 100644 --- a/PySide/QtGui/glue/qlayout_help_functions.h +++ b/PySide/QtGui/glue/qlayout_help_functions.h @@ -28,7 +28,7 @@ inline void addLayoutOwnership(QLayout* layout, QWidget* widget) inline void addLayoutOwnership(QLayout* layout, QLayout* other) { - //transfer all children widgetes from other to layout parent widget + //transfer all children widgets from other to layout parent widget QWidget* parent = layout->parentWidget(); if (!parent) { //keep the reference while the layout is orphan @@ -39,7 +39,11 @@ inline void addLayoutOwnership(QLayout* layout, QLayout* other) } for (int i=0, i_max=other->count(); i < i_max; i++) { - addLayoutOwnership(layout, other->itemAt(i)); + QLayoutItem* item = layout->itemAt(i); + if (PyErr_Occurred()) + return; + + addLayoutOwnership(layout, item); } Shiboken::AutoDecRef pyParent(Shiboken::Converter::toPython(layout)); diff --git a/PySide/QtGui/glue/qwidget_glue.h b/PySide/QtGui/glue/qwidget_glue.h index 0339e8980..d067d9f39 100644 --- a/PySide/QtGui/glue/qwidget_glue.h +++ b/PySide/QtGui/glue/qwidget_glue.h @@ -12,21 +12,20 @@ static inline void qwidgetReparentLayout(QWidget *parent, QLayout *layout) { Shiboken::AutoDecRef pyParent(Shiboken::Converter::toPython(parent)); - for (int i=0; i < layout->count(); i++) - { - QLayoutItem *item = layout->itemAt(i); - QWidget *w = item->widget(); - if (w) - { + for (int i=0; i < layout->count(); i++) { + QLayoutItem* item = layout->itemAt(i); + if (PyErr_Occurred()) + return; + + QWidget* w = item->widget(); + if (w) { QWidget* pw = w->parentWidget(); if (pw != parent) { Shiboken::AutoDecRef pyChild(Shiboken::Converter::toPython(w)); Shiboken::setParent(pyParent, pyChild); } - } - else - { - QLayout *l = item->layout(); + } else { + QLayout* l = item->layout(); if (l) qwidgetReparentLayout(parent, l); } @@ -58,6 +57,9 @@ static inline void qwidgetSetLayout(QWidget *self, QLayout *layout) if (oldParent != self) { qwidgetReparentLayout(self, layout); + if (PyErr_Occurred()) + return; + self->setLayout(layout); } } diff --git a/PySide/QtGui/typesystem_gui_common.xml b/PySide/QtGui/typesystem_gui_common.xml index 59b8aa14b..04ad22a8d 100644 --- a/PySide/QtGui/typesystem_gui_common.xml +++ b/PySide/QtGui/typesystem_gui_common.xml @@ -3371,6 +3371,7 @@ qwidgetSetLayout(%CPPSELF, %1); + // %FUNCTION_NAME() - disable generation of function call. -- cgit v1.2.3