Commit 36e6a705 authored by El Mehdi Fekari's avatar El Mehdi Fekari Committed by Mehdi Fekari

Debugger: Fix the way to register/add new debuggers

DebuggerItemManager::registerDebugger() should return the id
of the added debugger in order to use it when setting a kit's debugger
(addDebugger() creates and adds a copy of the passed
debugger object with a unique id).

The DebuggerKitInformation::setDebugger() method should set only already
existing and registered debuggers.

Task-number: QTCREATORBUG-10436

Change-Id: Icdcd1ed92aafe9eda44abf831aa9983dd6801980
Reviewed-by: default avatarhjk <hjk121@nokiamail.com>
Reviewed-by: default avatarDaniel Teske <daniel.teske@digia.com>
parent 9f66b638
......@@ -867,7 +867,8 @@ void AndroidConfigurations::updateAutomaticKitList()
debugger.setDisplayName(tr("Android Debugger for %1").arg(tc->displayName()));
debugger.setAutoDetected(true);
debugger.setAbi(tc->targetAbi());
Debugger::DebuggerKitInformation::setDebugger(newKit, debugger);
QVariant id = Debugger::DebuggerItemManager::registerDebugger(debugger);
Debugger::DebuggerKitInformation::setDebugger(newKit, id);
AndroidGdbServerKitInformation::setGdbSever(newKit, tc->suggestedGdbServer());
newKit->makeSticky();
......
......@@ -345,16 +345,11 @@ QString DebuggerKitInformation::displayString(const Kit *k)
return binary.isEmpty() ? tr("%1 <None>").arg(name) : tr("%1 using \"%2\"").arg(name, binary);
}
void DebuggerKitInformation::setDebugger(Kit *k, const DebuggerItem &item)
void DebuggerKitInformation::setDebugger(Kit *k, const QVariant &id)
{
// Only register reasonably complete debuggers.
QTC_ASSERT(!item.id().isValid(), return);
QTC_ASSERT(!item.command().isEmpty(), return);
QTC_ASSERT(!item.displayName().isEmpty(), return);
QTC_ASSERT(item.engineType() != NoEngineType, return);
// Only set registered/existing debuggers
QTC_ASSERT(DebuggerItemManager::findByCommand(item.command()), return);
k->setValue(DebuggerKitInformation::id(), item.id());
QTC_ASSERT(DebuggerItemManager::findById(id), return);
k->setValue(DebuggerKitInformation::id(), id);
}
Core::Id DebuggerKitInformation::id()
......@@ -651,11 +646,12 @@ void DebuggerItemManager::saveDebuggers()
// Do not save default debuggers as they are set by the SDK.
}
void DebuggerItemManager::registerDebugger(const DebuggerItem &item)
QVariant DebuggerItemManager::registerDebugger(const DebuggerItem &item)
{
if (findByCommand(item.command()))
return;
addDebugger(item);
return item.id();
return addDebugger(item);
}
void DebuggerItemManager::deregisterDebugger(const DebuggerItem &item)
......@@ -664,13 +660,17 @@ void DebuggerItemManager::deregisterDebugger(const DebuggerItem &item)
removeDebugger(item.id());
}
void DebuggerItemManager::addDebugger(const DebuggerItem& item0)
QVariant DebuggerItemManager::addDebugger(const DebuggerItem& item0)
{
DebuggerItem item = item0;
QTC_ASSERT(!item.command().isEmpty(), return QVariant());
QTC_ASSERT(!item.displayName().isEmpty(), return QVariant());
QTC_ASSERT(item.engineType() != NoEngineType, return QVariant());
if (item.id().isNull())
item.setId(QUuid::createUuid().toString());
m_debuggers.append(item);
m_model->addDebugger(item);
return item.id();
}
void DebuggerItemManager::removeDebugger(const QVariant &id)
......
......@@ -110,7 +110,7 @@ public:
static QList<DebuggerItem> debuggers();
static Debugger::Internal::DebuggerItemModel *model();
static void registerDebugger(const DebuggerItem &item);
static QVariant registerDebugger(const DebuggerItem &item);
static void deregisterDebugger(const DebuggerItem &item);
static const DebuggerItem *findByCommand(const Utils::FileName &command);
......@@ -121,7 +121,7 @@ public:
static void setItemData(const QVariant &id, const QString& displayName, const Utils::FileName &fileName);
static void removeDebugger(const QVariant &id);
static void addDebugger(const DebuggerItem &item);
static QVariant addDebugger(const DebuggerItem &item);
public slots:
void saveDebuggers();
......@@ -164,7 +164,7 @@ public:
ItemList toUserOutput(const ProjectExplorer::Kit *k) const;
static void setDebugger(ProjectExplorer::Kit *k, const DebuggerItem &item);
static void setDebugger(ProjectExplorer::Kit *k, const QVariant &id);
static Core::Id id();
static Utils::FileName debuggerCommand(const ProjectExplorer::Kit *k);
......
......@@ -316,7 +316,8 @@ void IosConfigurations::updateAutomaticKitList()
debugger.setDisplayName(tr("IOS Debugger"));
debugger.setAutoDetected(true);
debugger.setAbi(pToolchain->targetAbi());
Debugger::DebuggerKitInformation::setDebugger(newKit, debugger);
QVariant id = Debugger::DebuggerItemManager::registerDebugger(debugger);
Debugger::DebuggerKitInformation::setDebugger(newKit, id);
SysRootKitInformation::setSysRoot(newKit, p.sdkPath);
// QmakeProjectManager::QmakeKitInformation::setMkspec(newKit,
......
......@@ -237,8 +237,8 @@ Kit *BlackBerryConfiguration::createKit(QnxAbstractQtVersion *version, ToolChain
version->qtVersionString(), version->platformDisplayName(),
version->archString(), m_targetName));
DebuggerItemManager::registerDebugger(debugger);
DebuggerKitInformation::setDebugger(kit, debugger);
QVariant id = DebuggerItemManager::registerDebugger(debugger);
DebuggerKitInformation::setDebugger(kit, id);
if (isSimulator)
QmakeProjectManager::QmakeKitInformation::setMkspec(
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment