forked from qt-creator/qt-creator
Fix crashes when no default profile is set
* Handle 0 when calling createTarget to avoid the crashes in the first place * Do not try to create/add targets for 0 profiles to avoid creator writing a warning to the console * Fix possible crashes in debugger when no default profile is set. Task-number: QTCREATORBUG-7695 Change-Id: I9afc8e29c8b859ad078dad794ef5017168daac78 Reviewed-by: Orgad Shaneh <orgads@gmail.com> Reviewed-by: Eike Ziller <eike.ziller@nokia.com>
This commit is contained in:
@@ -158,8 +158,9 @@ bool AutotoolsProject::fromMap(const QVariantMap &map)
|
|||||||
// Load the project tree structure.
|
// Load the project tree structure.
|
||||||
evaluateBuildSystem();
|
evaluateBuildSystem();
|
||||||
|
|
||||||
if (!activeTarget())
|
Profile *defaultProfile = ProfileManager::instance()->defaultProfile();
|
||||||
addTarget(createTarget(ProfileManager::instance()->defaultProfile()));
|
if (!activeTarget() && defaultProfile)
|
||||||
|
addTarget(createTarget(defaultProfile));
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@@ -539,8 +539,9 @@ bool CMakeProject::fromMap(const QVariantMap &map)
|
|||||||
if (!Project::fromMap(map))
|
if (!Project::fromMap(map))
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
if (!activeTarget())
|
Profile *defaultProfile = ProfileManager::instance()->defaultProfile();
|
||||||
addTarget(createTarget(ProfileManager::instance()->defaultProfile()));
|
if (!activeTarget() && defaultProfile)
|
||||||
|
addTarget(createTarget(defaultProfile));
|
||||||
|
|
||||||
// We have a user file, but we could still be missing the cbp file
|
// We have a user file, but we could still be missing the cbp file
|
||||||
// or simply run createXml with the saved settings
|
// or simply run createXml with the saved settings
|
||||||
|
@@ -1317,7 +1317,8 @@ bool DebuggerPluginPrivate::parseArgument(QStringList::const_iterator &it,
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
DebuggerStartParameters sp;
|
DebuggerStartParameters sp;
|
||||||
fillParameters(&sp, ProfileManager::instance()->defaultProfile()->id());
|
Profile *defaultProfile = ProfileManager::instance()->defaultProfile();
|
||||||
|
fillParameters(&sp, defaultProfile ? defaultProfile->id() : Core::Id());
|
||||||
qulonglong pid = it->toULongLong();
|
qulonglong pid = it->toULongLong();
|
||||||
if (pid) {
|
if (pid) {
|
||||||
sp.startMode = AttachExternal;
|
sp.startMode = AttachExternal;
|
||||||
|
@@ -877,7 +877,7 @@ static DebuggerStartParameters localStartParameters(RunConfiguration *runConfigu
|
|||||||
|
|
||||||
Target *target = runConfiguration->target();
|
Target *target = runConfiguration->target();
|
||||||
Profile *profile = target ? target->profile() : ProfileManager::instance()->defaultProfile();
|
Profile *profile = target ? target->profile() : ProfileManager::instance()->defaultProfile();
|
||||||
fillParameters(&sp, profile->id());
|
fillParameters(&sp, profile ? profile->id() : Core::Id());
|
||||||
sp.environment = rc->environment();
|
sp.environment = rc->environment();
|
||||||
sp.workingDirectory = rc->workingDirectory();
|
sp.workingDirectory = rc->workingDirectory();
|
||||||
|
|
||||||
|
@@ -429,8 +429,9 @@ bool GenericProject::fromMap(const QVariantMap &map)
|
|||||||
if (!Project::fromMap(map))
|
if (!Project::fromMap(map))
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
if (!activeTarget())
|
Profile *defaultProfile = ProfileManager::instance()->defaultProfile();
|
||||||
addTarget(createTarget(ProfileManager::instance()->defaultProfile()));
|
if (!activeTarget() && defaultProfile)
|
||||||
|
addTarget(createTarget(defaultProfile));
|
||||||
|
|
||||||
// Sanity check: We need both a buildconfiguration and a runconfiguration!
|
// Sanity check: We need both a buildconfiguration and a runconfiguration!
|
||||||
QList<Target *> targetList = targets();
|
QList<Target *> targetList = targets();
|
||||||
|
@@ -248,7 +248,7 @@ bool Project::supportsProfile(Profile *p) const
|
|||||||
|
|
||||||
Target *Project::createTarget(Profile *p)
|
Target *Project::createTarget(Profile *p)
|
||||||
{
|
{
|
||||||
if (target(p))
|
if (!p || target(p))
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
Target *t = new Target(this, p);
|
Target *t = new Target(this, p);
|
||||||
|
@@ -300,8 +300,9 @@ bool QmlProject::fromMap(const QVariantMap &map)
|
|||||||
if (!Project::fromMap(map))
|
if (!Project::fromMap(map))
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
if (!activeTarget())
|
ProjectExplorer::Profile *defaultProfile = ProjectExplorer::ProfileManager::instance()->defaultProfile();
|
||||||
addTarget(createTarget(ProjectExplorer::ProfileManager::instance()->defaultProfile()));
|
if (!activeTarget() && defaultProfile)
|
||||||
|
addTarget(createTarget(defaultProfile));
|
||||||
|
|
||||||
refresh(Everything);
|
refresh(Everything);
|
||||||
// FIXME workaround to guarantee that run/debug actions are enabled if a valid file exists
|
// FIXME workaround to guarantee that run/debug actions are enabled if a valid file exists
|
||||||
|
Reference in New Issue
Block a user