Fix bug#552 - "Segmentation fault when using QUiLoader and QTabWidget"
Reviewer: Renato Araújo <renato.filho@openbossa.org>
Marcelo Lira <marcelo.lira@openbossa.org>
This commit is contained in:
parent
e9d1dc38e2
commit
4a2bfc9239
5 changed files with 68 additions and 3 deletions
|
|
@ -3748,7 +3748,6 @@
|
||||||
QWidget* tab = %CPPSELF.widget(%1);
|
QWidget* tab = %CPPSELF.widget(%1);
|
||||||
if (tab) {
|
if (tab) {
|
||||||
Shiboken::AutoDecRef pyWidget(%CONVERTTOPYTHON[QWidget*](tab));
|
Shiboken::AutoDecRef pyWidget(%CONVERTTOPYTHON[QWidget*](tab));
|
||||||
Shiboken::Object::setParent(0, pyWidget);
|
|
||||||
%CPPSELF.%FUNCTION_NAME(%1);
|
%CPPSELF.%FUNCTION_NAME(%1);
|
||||||
}
|
}
|
||||||
</inject-code>
|
</inject-code>
|
||||||
|
|
|
||||||
|
|
@ -112,8 +112,10 @@ static void destructionVisitor(SbkObject* pyObj, void* data)
|
||||||
PyTypeObject* pyQObjectType = reinterpret_cast<PyTypeObject*>(realData[1]);
|
PyTypeObject* pyQObjectType = reinterpret_cast<PyTypeObject*>(realData[1]);
|
||||||
|
|
||||||
if (pyObj != pyQApp && PyObject_TypeCheck(pyObj, pyQObjectType)) {
|
if (pyObj != pyQApp && PyObject_TypeCheck(pyObj, pyQObjectType)) {
|
||||||
if (Shiboken::Object::hasOwnership(pyObj))
|
if (Shiboken::Object::hasOwnership(pyObj) && Shiboken::Object::isValid(pyObj, false)) {
|
||||||
Shiboken::callCppDestructor<QObject>(Shiboken::Object::cppPointer(pyObj, Shiboken::SbkType<QObject*>()));
|
Shiboken::callCppDestructor<QObject>(Shiboken::Object::cppPointer(pyObj, pyQObjectType));
|
||||||
|
Shiboken::Object::setValidCpp(pyObj, false);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -2,5 +2,6 @@ PYSIDE_TEST(bug_360.py)
|
||||||
PYSIDE_TEST(bug_376.py)
|
PYSIDE_TEST(bug_376.py)
|
||||||
PYSIDE_TEST(bug_392.py)
|
PYSIDE_TEST(bug_392.py)
|
||||||
PYSIDE_TEST(bug_426.py)
|
PYSIDE_TEST(bug_426.py)
|
||||||
|
PYSIDE_TEST(bug_552.py)
|
||||||
PYSIDE_TEST(uiloader_test.py)
|
PYSIDE_TEST(uiloader_test.py)
|
||||||
PYSIDE_TEST(ui_test.py)
|
PYSIDE_TEST(ui_test.py)
|
||||||
|
|
|
||||||
21
tests/QtUiTools/bug_552.py
Normal file
21
tests/QtUiTools/bug_552.py
Normal file
|
|
@ -0,0 +1,21 @@
|
||||||
|
from helper import adjust_filename
|
||||||
|
from PySide import QtGui, QtCore
|
||||||
|
from PySide.QtUiTools import QUiLoader
|
||||||
|
|
||||||
|
class View_1(QtGui.QWidget):
|
||||||
|
|
||||||
|
def __init__(self):
|
||||||
|
QtGui.QWidget.__init__(self)
|
||||||
|
loader = QUiLoader()
|
||||||
|
widget = loader.load(adjust_filename('bug_552.ui', __file__), self)
|
||||||
|
self.children = []
|
||||||
|
for child in widget.findChildren(QtCore.QObject, None):
|
||||||
|
self.children.append(child)
|
||||||
|
self.t = widget.tabWidget
|
||||||
|
self.t.removeTab(0)
|
||||||
|
|
||||||
|
app = QtGui.QApplication([])
|
||||||
|
window = View_1()
|
||||||
|
window.show()
|
||||||
|
|
||||||
|
# If it doesn't crash it works :-)
|
||||||
42
tests/QtUiTools/bug_552.ui
Normal file
42
tests/QtUiTools/bug_552.ui
Normal file
|
|
@ -0,0 +1,42 @@
|
||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<ui version="4.0">
|
||||||
|
<class>Form</class>
|
||||||
|
<widget class="QWidget" name="Form">
|
||||||
|
<property name="geometry">
|
||||||
|
<rect>
|
||||||
|
<x>0</x>
|
||||||
|
<y>0</y>
|
||||||
|
<width>400</width>
|
||||||
|
<height>300</height>
|
||||||
|
</rect>
|
||||||
|
</property>
|
||||||
|
<property name="windowTitle">
|
||||||
|
<string>Form</string>
|
||||||
|
</property>
|
||||||
|
<widget class="QTabWidget" name="tabWidget">
|
||||||
|
<property name="geometry">
|
||||||
|
<rect>
|
||||||
|
<x>130</x>
|
||||||
|
<y>80</y>
|
||||||
|
<width>139</width>
|
||||||
|
<height>80</height>
|
||||||
|
</rect>
|
||||||
|
</property>
|
||||||
|
<property name="currentIndex">
|
||||||
|
<number>0</number>
|
||||||
|
</property>
|
||||||
|
<widget class="QWidget" name="tab">
|
||||||
|
<attribute name="title">
|
||||||
|
<string>Tab 1</string>
|
||||||
|
</attribute>
|
||||||
|
</widget>
|
||||||
|
<widget class="QWidget" name="tab_2">
|
||||||
|
<attribute name="title">
|
||||||
|
<string>Tab 2</string>
|
||||||
|
</attribute>
|
||||||
|
</widget>
|
||||||
|
</widget>
|
||||||
|
</widget>
|
||||||
|
<resources/>
|
||||||
|
<connections/>
|
||||||
|
</ui>
|
||||||
Loading…
Add table
Add a link
Reference in a new issue