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();
|
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;
|
||||||
|
|||||||
@@ -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;
|
||||||
|
|||||||
@@ -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());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -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
|
||||||
|
|||||||
Reference in New Issue
Block a user