Only raise 'RuntimeError' for function call to avoid problems with contructor order calls.
This commit is contained in:
parent
a2f110d3b9
commit
58fb1c705c
2 changed files with 12 additions and 4 deletions
|
|
@ -228,10 +228,10 @@ void initQObjectSubType(SbkObjectType* type, PyObject* args, PyObject* kwds)
|
||||||
|
|
||||||
PyObject* getMetaDataFromQObject(QObject* cppSelf, PyObject* self, PyObject* name)
|
PyObject* getMetaDataFromQObject(QObject* cppSelf, PyObject* self, PyObject* name)
|
||||||
{
|
{
|
||||||
if (!Shiboken::Object::isValid(self))
|
|
||||||
return 0;
|
|
||||||
|
|
||||||
PyObject* attr = PyObject_GenericGetAttr(self, name);
|
PyObject* attr = PyObject_GenericGetAttr(self, name);
|
||||||
|
if (!Shiboken::Object::isValid(reinterpret_cast<SbkObject*>(self), false))
|
||||||
|
return attr;
|
||||||
|
|
||||||
if (attr && Property::isPropertyType(attr)) {
|
if (attr && Property::isPropertyType(attr)) {
|
||||||
PyObject *value = Property::getValue(reinterpret_cast<PySideProperty*>(attr), self);
|
PyObject *value = Property::getValue(reinterpret_cast<PySideProperty*>(attr), self);
|
||||||
if (!value)
|
if (!value)
|
||||||
|
|
|
||||||
|
|
@ -34,9 +34,17 @@ class MainWindow(QMainWindow):
|
||||||
def __init__(self, *args):
|
def __init__(self, *args):
|
||||||
self._menu = QMenu(self.dontexist) # attribute called with invalid C++ object
|
self._menu = QMenu(self.dontexist) # attribute called with invalid C++ object
|
||||||
|
|
||||||
|
class MainWindow2(QMainWindow):
|
||||||
|
def __init__(self):
|
||||||
|
self.show()
|
||||||
|
|
||||||
class Bug696(UsesQApplication):
|
class Bug696(UsesQApplication):
|
||||||
def testContructorInitialization(self):
|
def testContructorInitialization(self):
|
||||||
self.assertRaises(RuntimeError, MainWindow)
|
self.assertRaises(AttributeError, MainWindow)
|
||||||
|
|
||||||
|
def testContructorInitializationAndCPPFunction(self):
|
||||||
|
self.assertRaises(RuntimeError, MainWindow2)
|
||||||
|
|
||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
unittest.main()
|
unittest.main()
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue