forked from qt-creator/qt-creator
ProfileChooser: make more robust in case of no configured profiles
Change-Id: I53945617cc616d2bfe4726b4e6e45cad7b400c44 Reviewed-by: Tobias Hunger <tobias.hunger@nokia.com>
This commit is contained in:
@@ -375,6 +375,7 @@ bool StartApplicationDialog::run(QWidget *parent, QSettings *settings, DebuggerS
|
||||
}
|
||||
|
||||
Profile *profile = dialog.d->profileChooser->currentProfile();
|
||||
QTC_ASSERT(profile, return false);
|
||||
fillParameters(sp, profile);
|
||||
|
||||
sp->executable = newParameters.localExecutable;
|
||||
|
||||
@@ -1702,10 +1702,12 @@ void DebuggerPluginPrivate::attachToQmlPort()
|
||||
if (dlg.exec() != QDialog::Accepted)
|
||||
return;
|
||||
|
||||
Profile *profile = dlg.profile();
|
||||
QTC_ASSERT(profile, return);
|
||||
setConfigValue(_("LastQmlServerPort"), dlg.port());
|
||||
setConfigValue(_("LastProfile"), dlg.profile()->id().toString());
|
||||
setConfigValue(_("LastProfile"), profile->id().toString());
|
||||
|
||||
fillParameters(&sp, dlg.profile());
|
||||
fillParameters(&sp, profile);
|
||||
sp.qmlServerAddress = sp.connParams.host;
|
||||
sp.qmlServerPort = dlg.port();
|
||||
sp.startMode = AttachToRemoteProcess;
|
||||
|
||||
@@ -37,6 +37,7 @@
|
||||
#include <projectexplorer/toolchain.h>
|
||||
|
||||
#include <utils/environment.h>
|
||||
#include <utils/qtcassert.h>
|
||||
|
||||
#include <QDir>
|
||||
#include <QPair>
|
||||
@@ -213,11 +214,12 @@ ProfileInformation::ItemList DebuggerProfileInformation::toUserOutput(Profile *p
|
||||
|
||||
FileName DebuggerProfileInformation::debuggerCommand(const Profile *p)
|
||||
{
|
||||
return FileName::fromString(p->value(Core::Id(DEBUGGER_INFORMATION)).toString());
|
||||
return FileName::fromString(p ? p->value(Core::Id(DEBUGGER_INFORMATION)).toString() : QString());
|
||||
}
|
||||
|
||||
void DebuggerProfileInformation::setDebuggerCommand(Profile *p, const FileName &command)
|
||||
{
|
||||
QTC_ASSERT(p, return);
|
||||
p->setValue(Core::Id(DEBUGGER_INFORMATION), command.toString());
|
||||
}
|
||||
|
||||
|
||||
@@ -50,6 +50,8 @@ void ProfileChooser::onCurrentIndexChanged(int index)
|
||||
{
|
||||
if (Profile *profile = profileAt(index))
|
||||
setToolTip(profile->toHtml());
|
||||
else
|
||||
setToolTip(QString());
|
||||
}
|
||||
|
||||
void ProfileChooser::populate(unsigned flags)
|
||||
@@ -78,7 +80,8 @@ void ProfileChooser::populate(unsigned flags)
|
||||
|
||||
Profile *ProfileChooser::currentProfile() const
|
||||
{
|
||||
return profileAt(currentIndex());
|
||||
const int index = currentIndex();
|
||||
return index == -1 ? 0 : profileAt(index);
|
||||
}
|
||||
|
||||
void ProfileChooser::setCurrentProfileId(Core::Id id)
|
||||
@@ -93,7 +96,8 @@ void ProfileChooser::setCurrentProfileId(Core::Id id)
|
||||
|
||||
Core::Id ProfileChooser::currentProfileId() const
|
||||
{
|
||||
return profileAt(currentIndex())->id();
|
||||
Profile *profile = currentProfile();
|
||||
return profile ? profile->id() : Core::Id();
|
||||
}
|
||||
|
||||
Profile *ProfileChooser::profileAt(int index) const
|
||||
|
||||
Reference in New Issue
Block a user