Commit cd17a0e4 authored by hjk's avatar hjk

Debugger: Don't add invalid items during validation

Change-Id: I3b6427ec038d61ea3166880ae51292f87f7b861b
Reviewed-by: default avatarFriedemann Kleint <Friedemann.Kleint@digia.com>
Reviewed-by: default avatarhjk <hjk121@nokiamail.com>
parent 48d1e8eb
......@@ -265,6 +265,7 @@ static inline QSettings *userSettings()
|| lowerFile.startsWith(QLatin1String("toolchains.xml"))
|| lowerFile.startsWith(QLatin1String("qtversion.xml"))
|| lowerFile.startsWith(QLatin1String("devices.xml"))
|| lowerFile.startsWith(QLatin1String("debuggers.xml"))
|| lowerFile.startsWith(QLatin1String("qtcreator.")))
QFile::copy(srcDir.absoluteFilePath(file), destDir.absoluteFilePath(file));
if (file == QLatin1String("qtcreator"))
......
......@@ -788,7 +788,7 @@ void AndroidConfigurations::updateAutomaticKitList()
ToolChainKitInformation::setToolChain(newKit, tc);
QtSupport::QtKitInformation::setQtVersion(newKit, qt);
DeviceKitInformation::setDevice(newKit, device);
Debugger::DebuggerKitInformation::setDebuggerItem(newKit,
Debugger::DebuggerKitInformation::setDebugger(newKit,
Debugger::GdbEngineType, tc->suggestedDebugger());
AndroidGdbServerKitInformation::setGdbSever(newKit, tc->suggestedGdbServer());
newKit->makeSticky();
......
......@@ -121,7 +121,7 @@ bool DebuggerKitChooser::kitMatches(const ProjectExplorer::Kit *k) const
QString DebuggerKitChooser::kitToolTip(Kit *k) const
{
return DebuggerKitInformation::debuggerItem(k).userOutput();
return DebuggerKitInformation::displayString(k);
}
///////////////////////////////////////////////////////////////////////
......
......@@ -53,7 +53,9 @@ QT_END_NAMESPACE
namespace Debugger {
namespace Internal {
class DebuggerItem;
class DebuggerItemConfigWidget;
class DebuggerKitConfigWidget;
// -----------------------------------------------------------------------
// DebuggerItemManager
......@@ -67,51 +69,53 @@ public:
DebuggerItemManager(QObject *parent);
~DebuggerItemManager();
QList<DebuggerItem *> debuggers() const { return m_debuggers; }
QList<DebuggerItem *> findDebuggers(const ProjectExplorer::Abi &abi) const;
DebuggerItem *currentDebugger() const { return m_currentDebugger; }
static DebuggerItem *debuggerFromId(const QVariant &id);
static DebuggerItem *debuggerFromPath(const QString &path);
static const DebuggerItem *debuggerFromKit(const ProjectExplorer::Kit *kit);
void setDebugger(ProjectExplorer::Kit *kit,
DebuggerEngineType type, const Utils::FileName &command);
QModelIndex currentIndex() const;
void setCurrentIndex(const QModelIndex &index);
void setCurrentData(const QString &displayName, const Utils::FileName &fileName);
bool isLoaded() const;
void updateCurrentItem();
// Returns id.
QVariant defaultDebugger(ProjectExplorer::ToolChain *tc);
// Adds item unless present. Return id of a matching item.
QVariant maybeAddDebugger(const DebuggerItem &item, bool makeCurrent = true);
static void restoreDebuggers();
public slots:
void saveDebuggers();
void autoDetectDebuggers();
void readLegacyDebuggers();
void addDebugger();
void cloneDebugger();
void removeDebugger();
void markCurrentDirty();
signals:
void debuggerAdded(DebuggerItem *item);
void debuggerRemoved(DebuggerItem *item);
void debuggerUpdated(DebuggerItem *item);
void debuggerAdded(const QVariant &id, const QString &display);
void debuggerUpdated(const QVariant &id, const QString &display);
void debuggerRemoved(const QVariant &id);
private:
friend class Debugger::DebuggerKitInformation;
friend class DebuggerKitConfigWidget;
friend class DebuggerItemConfigWidget;
friend class DebuggerOptionsPage;
QVariant headerData(int section, Qt::Orientation orientation, int role) const;
QVariant doAddDebugger(const DebuggerItem &item);
const DebuggerItem *findByCommand(const Utils::FileName &command);
const DebuggerItem *findById(const QVariant &id);
QStandardItem *currentStandardItem() const;
QVariant headerData(int section, Qt::Orientation orientation, int role) const;
QString uniqueDisplayName(const QString &base) const;
void autoDetectCdbDebugger();
QMap<QString, Utils::FileName> m_abiToDebugger;
Utils::PersistentSettingsWriter *m_writer;
QList<DebuggerItem *> m_debuggers;
DebuggerItem *m_currentDebugger;
QList<DebuggerItem> m_debuggers;
QVariant m_currentDebugger;
QStandardItem *m_autoRoot;
QStandardItem *m_manualRoot;
QStringList added;
QStringList removed;
QHash<DebuggerItem *, QStandardItem *> m_itemFromDebugger;
QHash<QStandardItem *, DebuggerItem *> m_debuggerFromItem;
};
// -----------------------------------------------------------------------
......@@ -135,12 +139,12 @@ public:
private slots:
void manageDebuggers();
void currentDebuggerChanged(int idx);
void onDebuggerAdded(DebuggerItem *);
void onDebuggerUpdated(DebuggerItem *);
void onDebuggerRemoved(DebuggerItem *);
void onDebuggerAdded(const QVariant &id, const QString &displayName);
void onDebuggerUpdated(const QVariant &id, const QString &displayName);
void onDebuggerRemoved(const QVariant &id);
private:
int indexOf(const DebuggerItem *debugger);
int indexOf(const QVariant &id);
QVariant currentId() const;
void updateComboBox(const QVariant &id);
......
......@@ -38,30 +38,6 @@
namespace Debugger {
class DEBUGGER_EXPORT DebuggerItem
{
public:
DebuggerItem();
bool looksLike(const DebuggerItem &rhs) const;
bool canClone() const { return true; }
bool isValid() const { return true; }
QString engineTypeName() const;
QString userOutput() const;
QVariantMap toMap() const;
void fromMap(const QVariantMap &data);
void reinitializeFromFile();
public:
QVariant id;
QString displayName;
DebuggerEngineType engineType;
Utils::FileName command;
bool isAutoDetected;
QList<ProjectExplorer::Abi> abis;
};
class DEBUGGER_EXPORT DebuggerKitInformation : public ProjectExplorer::KitInformation
{
Q_OBJECT
......@@ -83,26 +59,16 @@ public:
ItemList toUserOutput(const ProjectExplorer::Kit *k) const;
static DebuggerItem debuggerItem(const ProjectExplorer::Kit *k);
static void setDebuggerItem(ProjectExplorer::Kit *k,
static void setDebugger(ProjectExplorer::Kit *k,
DebuggerEngineType type, const Utils::FileName &command);
static Utils::FileName debuggerCommand(const ProjectExplorer::Kit *k)
{ return debuggerItem(k).command; }
static void setDebuggerCommand(ProjectExplorer::Kit *k, const Utils::FileName &command);
static DebuggerEngineType engineType(const ProjectExplorer::Kit *k)
{ return debuggerItem(k).engineType; }
static Utils::FileName debuggerCommand(const ProjectExplorer::Kit *k);
static DebuggerEngineType engineType(const ProjectExplorer::Kit *k);
static QString displayString(const ProjectExplorer::Kit *k);
static void setSticky(ProjectExplorer::Kit *k, bool b);
};
inline bool operator==(const DebuggerItem &i1, const DebuggerItem &i2)
{ return i1.looksLike(i2); }
inline bool operator!=(const DebuggerItem &i1, const DebuggerItem &i2)
{ return !i1.looksLike(i2); }
} // namespace Debugger
#endif // DEBUGGER_DEBUGGERKITINFORMATION_H
......@@ -1627,8 +1627,7 @@ void DebuggerPluginPrivate::attachCore()
DebuggerStartParameters sp;
QString display = dlg.useLocalCoreFile() ? dlg.localCoreFile() : dlg.remoteCoreFile();
QTC_ASSERT(fillParameters(&sp, dlg.kit()), return);
DebuggerItem info = DebuggerKitInformation::debuggerItem(dlg.kit());
sp.masterEngineType = info.engineType;
sp.masterEngineType = DebuggerKitInformation::engineType(dlg.kit());
sp.executable = dlg.localExecutableFile();
sp.coreFile = dlg.localCoreFile();
sp.displayName = tr("Core file \"%1\"").arg(display);
......
......@@ -264,12 +264,12 @@ Kit *BlackBerryConfiguration::createKit(QnxArchitecture arch, BaseQtVersion *qtV
QtKitInformation::setQtVersion(kit, qtVersion);
ToolChainKitInformation::setToolChain(kit, tc);
if (arch == X86) {
Debugger::DebuggerKitInformation::setDebuggerCommand(kit, m_simulatorDebuger);
Debugger::DebuggerKitInformation::setDebugger(kit, Debugger::GdbEngineType, m_simulatorDebuger);
Qt4ProjectManager::QmakeKitInformation::setMkspec(kit, FileName::fromString(QString::fromLatin1("blackberry-x86-qcc")));
// TODO: Check if the name already exists(?)
kit->setDisplayName(tr("BlackBerry 10 (%1 - %2) - Simulator").arg(qtVersion->qtVersionString(), m_targetName));
} else {
Debugger::DebuggerKitInformation::setDebuggerCommand(kit, m_deviceDebuger);
Debugger::DebuggerKitInformation::setDebugger(kit, Debugger::GdbEngineType, m_deviceDebuger);
kit->setDisplayName(tr("BlackBerry 10 (%1 - %2)").arg(qtVersion->qtVersionString(), m_targetName));
}
......
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