From 1f55453df6ee1986242e684841219b7cb9b3b235 2013-01-29 10:08:00 From: florianlink Date: 2013-01-29 10:08:00 Subject: [PATCH] improved code generation for virtual functions to support overriding getter slots that are named as properties git-svn-id: svn://svn.code.sf.net/p/pythonqt/code/trunk@240 ea8d5007-eb21-0410-b261-ccb3ea6e24a9 --- diff --git a/generator/shellimplgenerator.cpp b/generator/shellimplgenerator.cpp index dfd27b4..4122e4c 100644 --- a/generator/shellimplgenerator.cpp +++ b/generator/shellimplgenerator.cpp @@ -125,9 +125,9 @@ void ShellImplGenerator::write(QTextStream &s, const AbstractMetaClass *meta_cla AbstractMetaArgumentList args = fun->arguments(); s << "if (_wrapper) {" << endl; - s << " PyObject* obj = PyObject_GetAttrString((PyObject*)_wrapper, \"" << fun->name() << "\");" << endl; - s << " PyErr_Clear();" << endl; - s << " if (obj && !PythonQtSlotFunction_Check(obj)) {" << endl; + s << " static PyObject* name = PyString_FromString(\"" << fun->name() << "\");" << endl; + s << " PyObject* obj = PyBaseObject_Type.tp_getattro((PyObject*)_wrapper, name);" << endl; + s << " if (obj) {" << endl; s << " static const char* argumentList[] ={\""; if (hasReturnValue) { // write the arguments, return type first @@ -176,6 +176,8 @@ void ShellImplGenerator::write(QTextStream &s, const AbstractMetaClass *meta_cla } else { s << " return;" << endl; } + s << " } else {" << endl; + s << " PyErr_Clear();" << endl; s << " }" << endl; s << "}" << endl;