From 659ee09ce4d9fb7e559e48839c7bfc49d0f60f48 Mon Sep 17 00:00:00 2001 From: hjk Date: Tue, 15 Oct 2013 15:10:18 +0200 Subject: [PATCH] Fix association of kits with auto-detected debuggers Task-number: QTCREATORBUG-10379 Change-Id: I515da97e6f6ac079590c9d91317ed32b5194a12a Reviewed-by: Friedemann Kleint --- .../debugger/debuggerkitconfigwidget.cpp | 70 ++++++++++++------- 1 file changed, 46 insertions(+), 24 deletions(-) diff --git a/src/plugins/debugger/debuggerkitconfigwidget.cpp b/src/plugins/debugger/debuggerkitconfigwidget.cpp index 06467f50f06..c2955fa7988 100644 --- a/src/plugins/debugger/debuggerkitconfigwidget.cpp +++ b/src/plugins/debugger/debuggerkitconfigwidget.cpp @@ -112,26 +112,6 @@ enum DebuggerConfigurationErrors { DebuggerNeedsAbsolutePath = 0x8 }; -static QVariant debuggerPathOrId(const Kit *k) -{ - QTC_ASSERT(k, return QString()); - QVariant id = k->value(DebuggerKitInformation::id()); - if (!id.isValid()) - return id; // Invalid. - - // With 3.0 we have: - // {75ecf347-f221-44c3-b613-ea1d29929cd4} - if (id.type() == QVariant::String) - return id; - - // Before we had: - // - // /data/dev/debugger/gdb-git/gdb/gdb - // 1 - // - return id.toMap().value(QLatin1String("Binary")); -} - static unsigned debuggerConfigurationErrors(const Kit *k) { QTC_ASSERT(k, return NoDebugger); @@ -167,13 +147,54 @@ const DebuggerItem *DebuggerKitInformation::debugger(const Kit *kit) { if (!kit) return 0; - QVariant pathOrId = debuggerPathOrId(kit); + + const QVariant id = kit->value(DebuggerKitInformation::id()); + + enum Detection { NotDetected, DetectedAutomatically, DetectedByFile, DetectedById }; + Detection detection = NotDetected; + + DebuggerEngineType autoEngine = NoEngineType; + + FileName fileName; + + // With 3.0 we have: + // {75ecf347-f221-44c3-b613-ea1d29929cd4} + // Before we had: + // + // /data/dev/debugger/gdb-git/gdb/gdb + // 1 + // + // Or for force auto-detected CDB + // + // auto + // 4 + // + + if (id.type() == QVariant::String) { + detection = DetectedById; + } else { + QMap map = id.toMap(); + QString binary = map.value(QLatin1String("Binary")).toString(); + if (binary == QLatin1String("auto")) { + detection = DetectedAutomatically; + autoEngine = DebuggerEngineType(map.value(QLatin1String("EngineType")).toInt()); + } else { + detection = DetectedByFile; + fileName = FileName::fromUserInput(binary); + } + } + + QTC_CHECK(detection != NotDetected); + foreach (const DebuggerItem &item, DebuggerItemManager::debuggers()) { - if (item.id() == pathOrId) + if (detection == DetectedById && item.id() == id) return &item; - if (item.command() == FileName::fromUserInput(pathOrId.toString())) + if (detection == DetectedByFile && item.command() == fileName) + return &item; + if (detection == DetectedAutomatically && item.engineType() == autoEngine) return &item; } + return 0; } @@ -457,6 +478,8 @@ void DebuggerItemManager::readLegacyDebuggers() continue; if (fn.startsWith(QLatin1Char('{'))) continue; + if (fn == QLatin1String("auto")) + continue; FileName command = FileName::fromUserInput(fn); if (findByCommand(command)) continue; @@ -560,7 +583,6 @@ void DebuggerItemManager::registerDebugger(const DebuggerItem &item) { if (findByCommand(item.command())) return; - addDebugger(item); }