Blob Blame History Raw
From 3a22e526c22d1773451c582ad121e8a857f821c1 Mon Sep 17 00:00:00 2001
From: Chris Burel <chrisburel@gmail.com>
Date: Mon, 3 Oct 2016 14:27:37 -0700
Subject: [PATCH 2/3] Fix isDerivedFrom() to return the inheritance distance
 between the two classes.
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

Previously isDerivedFrom() only returned 1 or -1, indicating a match or not
a match.

Signed-off-by: Petr Písař <ppisar@redhat.com>
---
 qtcore/src/util.cpp | 9 +++++----
 1 file changed, 5 insertions(+), 4 deletions(-)

diff --git a/qtcore/src/util.cpp b/qtcore/src/util.cpp
index 4c94e2c..eb52cdc 100644
--- a/qtcore/src/util.cpp
+++ b/qtcore/src/util.cpp
@@ -412,13 +412,14 @@ int isDerivedFrom(Smoke *smoke, Smoke::Index classId, Smoke *baseSmoke, Smoke::I
 
     for(Smoke::Index p = smoke->classes[classId].parents; smoke->inheritanceList[p]; p++) {
         Smoke::Class& cur = smoke->classes[smoke->inheritanceList[p]];
+        int newCount;
         if (cur.external) {
             Smoke::ModuleIndex mi = smoke->findClass(cur.className);
-            if (isDerivedFrom(mi.smoke, mi.index, baseSmoke, baseId, count) != -1)
-                return count;
+            if ((newCount = isDerivedFrom(mi.smoke, mi.index, baseSmoke, baseId, count)) != -1)
+                return newCount;
         }
-        if (isDerivedFrom(smoke, smoke->inheritanceList[p], baseSmoke, baseId, count) != -1)
-            return count;
+        if ((newCount = isDerivedFrom(smoke, smoke->inheritanceList[p], baseSmoke, baseId, count)) != -1)
+            return newCount;
     }
     return -1;
 }
-- 
2.7.4