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:
hjk
2012-08-24 14:45:25 +02:00
parent d39fc8088c
commit 29ec32a531
4 changed files with 14 additions and 5 deletions

View File

@@ -375,6 +375,7 @@ bool StartApplicationDialog::run(QWidget *parent, QSettings *settings, DebuggerS
} }
Profile *profile = dialog.d->profileChooser->currentProfile(); Profile *profile = dialog.d->profileChooser->currentProfile();
QTC_ASSERT(profile, return false);
fillParameters(sp, profile); fillParameters(sp, profile);
sp->executable = newParameters.localExecutable; sp->executable = newParameters.localExecutable;

View File

@@ -1702,10 +1702,12 @@ void DebuggerPluginPrivate::attachToQmlPort()
if (dlg.exec() != QDialog::Accepted) if (dlg.exec() != QDialog::Accepted)
return; return;
Profile *profile = dlg.profile();
QTC_ASSERT(profile, return);
setConfigValue(_("LastQmlServerPort"), dlg.port()); 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.qmlServerAddress = sp.connParams.host;
sp.qmlServerPort = dlg.port(); sp.qmlServerPort = dlg.port();
sp.startMode = AttachToRemoteProcess; sp.startMode = AttachToRemoteProcess;

View File

@@ -37,6 +37,7 @@
#include <projectexplorer/toolchain.h> #include <projectexplorer/toolchain.h>
#include <utils/environment.h> #include <utils/environment.h>
#include <utils/qtcassert.h>
#include <QDir> #include <QDir>
#include <QPair> #include <QPair>
@@ -213,11 +214,12 @@ ProfileInformation::ItemList DebuggerProfileInformation::toUserOutput(Profile *p
FileName DebuggerProfileInformation::debuggerCommand(const 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) void DebuggerProfileInformation::setDebuggerCommand(Profile *p, const FileName &command)
{ {
QTC_ASSERT(p, return);
p->setValue(Core::Id(DEBUGGER_INFORMATION), command.toString()); p->setValue(Core::Id(DEBUGGER_INFORMATION), command.toString());
} }

View File

@@ -50,6 +50,8 @@ void ProfileChooser::onCurrentIndexChanged(int index)
{ {
if (Profile *profile = profileAt(index)) if (Profile *profile = profileAt(index))
setToolTip(profile->toHtml()); setToolTip(profile->toHtml());
else
setToolTip(QString());
} }
void ProfileChooser::populate(unsigned flags) void ProfileChooser::populate(unsigned flags)
@@ -78,7 +80,8 @@ void ProfileChooser::populate(unsigned flags)
Profile *ProfileChooser::currentProfile() const Profile *ProfileChooser::currentProfile() const
{ {
return profileAt(currentIndex()); const int index = currentIndex();
return index == -1 ? 0 : profileAt(index);
} }
void ProfileChooser::setCurrentProfileId(Core::Id id) void ProfileChooser::setCurrentProfileId(Core::Id id)
@@ -93,7 +96,8 @@ void ProfileChooser::setCurrentProfileId(Core::Id id)
Core::Id ProfileChooser::currentProfileId() const Core::Id ProfileChooser::currentProfileId() const
{ {
return profileAt(currentIndex())->id(); Profile *profile = currentProfile();
return profile ? profile->id() : Core::Id();
} }
Profile *ProfileChooser::profileAt(int index) const Profile *ProfileChooser::profileAt(int index) const