Menu

Commit [r67]  Maximize  Restore  History

enabled downcasting only on base classes

florianlink 2009-04-22

changed /trunk/src/PythonQtClassInfo.cpp
/trunk/src/PythonQtClassInfo.cpp Diff Switch to side-by-side view
--- a/trunk/src/PythonQtClassInfo.cpp
+++ b/trunk/src/PythonQtClassInfo.cpp
@@ -695,7 +695,19 @@
 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 {
Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.