From dedc78b3fef25e04cf436ca462714ad8dc0329cd Mon Sep 17 00:00:00 2001 From: Marcelo Lira Date: Fri, 24 Sep 2010 15:47:41 -0300 Subject: Fixed segmentation fault libpyside's signalUpdateSource function. This function is called when an object is instantiated, and it will go through the class attributes looking for signals and what else is relevant. If the user has set a new attribute in the constructor before the call to its parent QObject-like __init__ method, a segmentation fault would ensue. This commit fixes this condition and also adds an unit test. Reviewed by Hugo Parente Reviewed by Luciano Wolf --- tests/QtCore/CMakeLists.txt | 1 + tests/QtCore/qobject_objectproperty_test.py | 29 +++++++++++++++++++++++++++++ 2 files changed, 30 insertions(+) create mode 100644 tests/QtCore/qobject_objectproperty_test.py (limited to 'tests') diff --git a/tests/QtCore/CMakeLists.txt b/tests/QtCore/CMakeLists.txt index 76db54f25..210aa01de 100644 --- a/tests/QtCore/CMakeLists.txt +++ b/tests/QtCore/CMakeLists.txt @@ -34,6 +34,7 @@ PYSIDE_TEST(qobject_connect_notify_test.py) PYSIDE_TEST(qobject_destructor.py) PYSIDE_TEST(qobject_event_filter_test.py) PYSIDE_TEST(qobject_inherits_test.py) +PYSIDE_TEST(qobject_objectproperty_test.py) PYSIDE_TEST(qobject_parent_test.py) PYSIDE_TEST(qobject_property_test.py) PYSIDE_TEST(qobject_protected_methods_test.py) diff --git a/tests/QtCore/qobject_objectproperty_test.py b/tests/QtCore/qobject_objectproperty_test.py new file mode 100644 index 000000000..2456b82cf --- /dev/null +++ b/tests/QtCore/qobject_objectproperty_test.py @@ -0,0 +1,29 @@ +#!/usr/bin/python +# -*- coding: utf-8 -*- +'''Test case for the bug #378 +http://bugs.openbossa.org/show_bug.cgi?id=378 +''' + +import unittest +from PySide.QtCore import QObject + +class ExtQObject(QObject): + def __init__(self): + # "foobar" will become a object attribute that will not be + # listed on the among the type attributes. Thus for bug + # condition be correctly triggered the "foobar" attribute + # must not previously exist in the parent class. + self.foobar = None + # The parent __init__ method must be called after the + # definition of "self.foobar". + QObject.__init__(self) + +class TestBug378(unittest.TestCase): + '''Test case for the bug #378''' + + def testBug378(self): + obj = ExtQObject() + +if __name__ == '__main__': + unittest.main() + -- cgit v1.2.3