From 8293debcc536e08b756f31594737a0a9ee16fea4 2009-04-22 06:52:00 From: florianlink Date: 2009-04-22 06:52:00 Subject: [PATCH] enabled downcasting only on base classes git-svn-id: svn://svn.code.sf.net/p/pythonqt/code/trunk@67 ea8d5007-eb21-0410-b261-ccb3ea6e24a9 --- diff --git a/src/PythonQtClassInfo.cpp b/src/PythonQtClassInfo.cpp index e033177..53d836f 100644 --- a/src/PythonQtClassInfo.cpp +++ b/src/PythonQtClassInfo.cpp @@ -695,7 +695,19 @@ void* PythonQtClassInfo::recursiveCastDownIfPossible(void* ptr, char** resultCla void* PythonQtClassInfo::castDownIfPossible(void* ptr, PythonQtClassInfo** resultClassInfo) { char* className; - void* resultPtr = recursiveCastDownIfPossible(ptr, &className); + // this would do downcasting recursively... + // void* resultPtr = recursiveCastDownIfPossible(ptr, &className); + + // we only do downcasting on the base object, not on the whole inheritance tree... + void* resultPtr = NULL; + if (!_polymorphicHandlers.isEmpty()) { + foreach(PythonQtPolymorphicHandlerCB* cb, _polymorphicHandlers) { + resultPtr = (*cb)(ptr, &className); + if (resultPtr) { + break; + } + } + } if (resultPtr) { *resultClassInfo = PythonQt::priv()->getClassInfo(className); } else {