forked from qt-creator/qt-creator
Project: Avoid unnecessary activeTargetChanged signal
Make sure to create the active target first when reading a project for the user data. This implicitly sets this target to the active one, avoiding one spurious activeTargetChanged signal. Change-Id: Iff9b19ed25bac9809ae75489ae159ffb66e71cb4 Reviewed-by: Tim Jenssen <tim.jenssen@qt.io>
This commit is contained in:
@@ -665,24 +665,33 @@ Project::RestoreResult Project::fromMap(const QVariantMap &map, QString *errorMe
|
|||||||
if (!ok || active < 0 || active >= maxI)
|
if (!ok || active < 0 || active >= maxI)
|
||||||
active = 0;
|
active = 0;
|
||||||
|
|
||||||
|
if (active >= 0 && active < maxI)
|
||||||
|
createTargetFromMap(map, active); // sets activeTarget since it is the first target created!
|
||||||
|
|
||||||
for (int i = 0; i < maxI; ++i) {
|
for (int i = 0; i < maxI; ++i) {
|
||||||
const QString key(QString::fromLatin1(TARGET_KEY_PREFIX) + QString::number(i));
|
if (i == active) // already covered!
|
||||||
if (!map.contains(key))
|
|
||||||
continue;
|
|
||||||
QVariantMap targetMap = map.value(key).toMap();
|
|
||||||
|
|
||||||
Target *t = restoreTarget(targetMap);
|
|
||||||
if (!t)
|
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
addTarget(t);
|
createTargetFromMap(map, i);
|
||||||
if (i == active)
|
|
||||||
setActiveTarget(t);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return RestoreResult::Ok;
|
return RestoreResult::Ok;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void Project::createTargetFromMap(const QVariantMap &map, int index)
|
||||||
|
{
|
||||||
|
const QString key = QString::fromLatin1(TARGET_KEY_PREFIX) + QString::number(index);
|
||||||
|
if (!map.contains(key))
|
||||||
|
return;
|
||||||
|
QVariantMap targetMap = map.value(key).toMap();
|
||||||
|
|
||||||
|
Target *t = restoreTarget(targetMap);
|
||||||
|
if (!t)
|
||||||
|
return;
|
||||||
|
|
||||||
|
addTarget(t);
|
||||||
|
}
|
||||||
|
|
||||||
EditorConfiguration *Project::editorConfiguration() const
|
EditorConfiguration *Project::editorConfiguration() const
|
||||||
{
|
{
|
||||||
return &d->m_editorConfiguration;
|
return &d->m_editorConfiguration;
|
||||||
|
|||||||
@@ -218,6 +218,7 @@ signals:
|
|||||||
|
|
||||||
protected:
|
protected:
|
||||||
virtual RestoreResult fromMap(const QVariantMap &map, QString *errorMessage);
|
virtual RestoreResult fromMap(const QVariantMap &map, QString *errorMessage);
|
||||||
|
void createTargetFromMap(const QVariantMap &map, int index);
|
||||||
virtual bool setupTarget(Target *t);
|
virtual bool setupTarget(Target *t);
|
||||||
|
|
||||||
// Helper methods to manage parsing state and signalling
|
// Helper methods to manage parsing state and signalling
|
||||||
|
|||||||
Reference in New Issue
Block a user