diff options
author | Renato Filho <renato.filho@openbossa.org> | 2011-03-22 11:12:33 -0300 |
---|---|---|
committer | Hugo Parente Lima <hugo.pl@gmail.com> | 2012-03-08 16:54:04 -0300 |
commit | 58fb1c705c7c3e6fae2aa4f295991d005f4e63ae (patch) | |
tree | dbfbc6b7548417029c9114be1bfefb1286e78819 | |
parent | a2f110d3b93de001964c879993110e96d248ad63 (diff) |
Only raise 'RuntimeError' for function call to avoid problems with contructor order calls.
-rw-r--r-- | libpyside/pyside.cpp | 6 | ||||
-rw-r--r-- | tests/QtGui/bug_696.py | 10 |
2 files changed, 12 insertions, 4 deletions
diff --git a/libpyside/pyside.cpp b/libpyside/pyside.cpp index 7fe39ead7..ec710a517 100644 --- a/libpyside/pyside.cpp +++ b/libpyside/pyside.cpp @@ -228,10 +228,10 @@ void initQObjectSubType(SbkObjectType* type, PyObject* args, PyObject* kwds) PyObject* getMetaDataFromQObject(QObject* cppSelf, PyObject* self, PyObject* name) { - if (!Shiboken::Object::isValid(self)) - return 0; - PyObject* attr = PyObject_GenericGetAttr(self, name); + if (!Shiboken::Object::isValid(reinterpret_cast<SbkObject*>(self), false)) + return attr; + if (attr && Property::isPropertyType(attr)) { PyObject *value = Property::getValue(reinterpret_cast<PySideProperty*>(attr), self); if (!value) diff --git a/tests/QtGui/bug_696.py b/tests/QtGui/bug_696.py index b165d042c..ff62e7abe 100644 --- a/tests/QtGui/bug_696.py +++ b/tests/QtGui/bug_696.py @@ -34,9 +34,17 @@ class MainWindow(QMainWindow): def __init__(self, *args): self._menu = QMenu(self.dontexist) # attribute called with invalid C++ object +class MainWindow2(QMainWindow): + def __init__(self): + self.show() + class Bug696(UsesQApplication): def testContructorInitialization(self): - self.assertRaises(RuntimeError, MainWindow) + self.assertRaises(AttributeError, MainWindow) + + def testContructorInitializationAndCPPFunction(self): + self.assertRaises(RuntimeError, MainWindow2) + if __name__ == '__main__': unittest.main() |