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)
|
||||
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) {
|
||||
const QString key(QString::fromLatin1(TARGET_KEY_PREFIX) + QString::number(i));
|
||||
if (!map.contains(key))
|
||||
continue;
|
||||
QVariantMap targetMap = map.value(key).toMap();
|
||||
|
||||
Target *t = restoreTarget(targetMap);
|
||||
if (!t)
|
||||
if (i == active) // already covered!
|
||||
continue;
|
||||
|
||||
addTarget(t);
|
||||
if (i == active)
|
||||
setActiveTarget(t);
|
||||
createTargetFromMap(map, i);
|
||||
}
|
||||
|
||||
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
|
||||
{
|
||||
return &d->m_editorConfiguration;
|
||||
|
||||
@@ -218,6 +218,7 @@ signals:
|
||||
|
||||
protected:
|
||||
virtual RestoreResult fromMap(const QVariantMap &map, QString *errorMessage);
|
||||
void createTargetFromMap(const QVariantMap &map, int index);
|
||||
virtual bool setupTarget(Target *t);
|
||||
|
||||
// Helper methods to manage parsing state and signalling
|
||||
|
||||
Reference in New Issue
Block a user