forked from qt-creator/qt-creator
winrt: Fix crash when opening run configurations
The "Smuggle in the button" hack broke and made Creator crash when a run configuration is opened. Having a "proper" aspect for the arguments saves the day. Change-Id: I45646318f5e8c42fb1ed64c07de5728d9d08c431 Reviewed-by: hjk <hjk@qt.io>
This commit is contained in:
@@ -41,7 +41,9 @@
|
|||||||
|
|
||||||
#include <utils/qtcassert.h>
|
#include <utils/qtcassert.h>
|
||||||
#include <utils/qtcprocess.h>
|
#include <utils/qtcprocess.h>
|
||||||
|
#include <utils/fancylineedit.h>
|
||||||
|
|
||||||
|
#include <QLabel>
|
||||||
#include <QLayout>
|
#include <QLayout>
|
||||||
#include <QRegularExpression>
|
#include <QRegularExpression>
|
||||||
#include <QToolButton>
|
#include <QToolButton>
|
||||||
@@ -52,16 +54,92 @@ using namespace Utils;
|
|||||||
namespace WinRt {
|
namespace WinRt {
|
||||||
namespace Internal {
|
namespace Internal {
|
||||||
|
|
||||||
|
const char ARGUMENTS_KEY[] = "WinRt.BuildStep.Deploy.Arguments";
|
||||||
|
const char DEFAULTARGUMENTS_KEY[] = "WinRt.BuildStep.Deploy.DefaultArguments";
|
||||||
|
|
||||||
|
WinRtArgumentsAspect::WinRtArgumentsAspect() = default;
|
||||||
|
|
||||||
|
WinRtArgumentsAspect::~WinRtArgumentsAspect() = default;
|
||||||
|
|
||||||
|
void WinRtArgumentsAspect::addToLayout(ProjectExplorer::LayoutBuilder &builder)
|
||||||
|
{
|
||||||
|
QTC_CHECK(!m_lineEdit);
|
||||||
|
auto label = new QLabel(tr("Arguments:"));
|
||||||
|
label->setTextInteractionFlags(Qt::TextSelectableByMouse);
|
||||||
|
builder.addItem(label);
|
||||||
|
|
||||||
|
auto *layout = new QHBoxLayout();
|
||||||
|
m_lineEdit = new Utils::FancyLineEdit();
|
||||||
|
if (!m_value.isEmpty())
|
||||||
|
m_lineEdit->setText(m_value);
|
||||||
|
else if (!m_defaultValue.isEmpty())
|
||||||
|
m_lineEdit->setText(m_defaultValue);
|
||||||
|
connect(m_lineEdit, &Utils::FancyLineEdit::textEdited,
|
||||||
|
this, &WinRtArgumentsAspect::setValue);
|
||||||
|
layout->addWidget(m_lineEdit);
|
||||||
|
|
||||||
|
auto restoreDefaultButton = new QToolButton();
|
||||||
|
restoreDefaultButton->setText(tr("Restore Default Arguments"));
|
||||||
|
connect(restoreDefaultButton, &QToolButton::clicked,
|
||||||
|
this, &WinRtArgumentsAspect::restoreDefaultValue);
|
||||||
|
layout->addWidget(restoreDefaultButton);
|
||||||
|
builder.addItem(layout);
|
||||||
|
}
|
||||||
|
|
||||||
|
void WinRtArgumentsAspect::fromMap(const QVariantMap &map)
|
||||||
|
{
|
||||||
|
m_defaultValue = map.value(DEFAULTARGUMENTS_KEY).toString();
|
||||||
|
m_value = map.value(ARGUMENTS_KEY).toString();
|
||||||
|
}
|
||||||
|
|
||||||
|
void WinRtArgumentsAspect::toMap(QVariantMap &map) const
|
||||||
|
{
|
||||||
|
map.insert(DEFAULTARGUMENTS_KEY, m_defaultValue);
|
||||||
|
map.insert(ARGUMENTS_KEY, m_value);
|
||||||
|
}
|
||||||
|
|
||||||
|
void WinRtArgumentsAspect::setValue(const QString &value)
|
||||||
|
{
|
||||||
|
if (value == m_value)
|
||||||
|
return;
|
||||||
|
|
||||||
|
m_value = value;
|
||||||
|
if (m_lineEdit)
|
||||||
|
m_lineEdit->setText(value);
|
||||||
|
emit changed();
|
||||||
|
}
|
||||||
|
|
||||||
|
QString WinRtArgumentsAspect::value() const
|
||||||
|
{
|
||||||
|
return m_value;
|
||||||
|
}
|
||||||
|
|
||||||
|
void WinRtArgumentsAspect::setDefaultValue(const QString &value)
|
||||||
|
{
|
||||||
|
m_defaultValue = value;
|
||||||
|
}
|
||||||
|
|
||||||
|
QString WinRtArgumentsAspect::defaultValue() const
|
||||||
|
{
|
||||||
|
return m_defaultValue;
|
||||||
|
}
|
||||||
|
|
||||||
|
void WinRtArgumentsAspect::restoreDefaultValue()
|
||||||
|
{
|
||||||
|
if (m_defaultValue == m_value)
|
||||||
|
return;
|
||||||
|
|
||||||
|
setValue(m_defaultValue);
|
||||||
|
}
|
||||||
|
|
||||||
WinRtPackageDeploymentStep::WinRtPackageDeploymentStep(BuildStepList *bsl, Core::Id id)
|
WinRtPackageDeploymentStep::WinRtPackageDeploymentStep(BuildStepList *bsl, Core::Id id)
|
||||||
: AbstractProcessStep(bsl, id)
|
: AbstractProcessStep(bsl, id)
|
||||||
{
|
{
|
||||||
setDisplayName(tr("Run windeployqt"));
|
setDisplayName(tr("Run windeployqt"));
|
||||||
|
|
||||||
m_argsAspect = addAspect<BaseStringAspect>();
|
m_argsAspect = addAspect<WinRtArgumentsAspect>();
|
||||||
m_argsAspect->setDisplayStyle(BaseStringAspect::LineEditDisplay);
|
m_argsAspect->setDefaultValue(defaultWinDeployQtArguments());
|
||||||
m_argsAspect->setSettingsKey("WinRt.BuildStep.Deploy.Arguments");
|
|
||||||
m_argsAspect->setValue(defaultWinDeployQtArguments());
|
m_argsAspect->setValue(defaultWinDeployQtArguments());
|
||||||
m_argsAspect->setLabelText(tr("Arguments:"));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
bool WinRtPackageDeploymentStep::init()
|
bool WinRtPackageDeploymentStep::init()
|
||||||
@@ -221,23 +299,6 @@ void WinRtPackageDeploymentStep::stdOutput(const QString &line)
|
|||||||
AbstractProcessStep::stdOutput(line);
|
AbstractProcessStep::stdOutput(line);
|
||||||
}
|
}
|
||||||
|
|
||||||
BuildStepConfigWidget *WinRtPackageDeploymentStep::createConfigWidget()
|
|
||||||
{
|
|
||||||
auto widget = AbstractProcessStep::createConfigWidget();
|
|
||||||
|
|
||||||
auto restoreDefaultButton = new QToolButton(widget);
|
|
||||||
restoreDefaultButton->setText(tr("Restore Default Arguments"));
|
|
||||||
connect(restoreDefaultButton, &QToolButton::clicked, this, [this] {
|
|
||||||
m_argsAspect->setValue(defaultWinDeployQtArguments());
|
|
||||||
});
|
|
||||||
|
|
||||||
// Smuggle in the extra button. We know that there's exactly one aspect.
|
|
||||||
QTC_ASSERT(widget->layout()->count() == 2, return widget);
|
|
||||||
widget->layout()->itemAt(1)->layout()->addWidget(restoreDefaultButton);
|
|
||||||
|
|
||||||
return widget;
|
|
||||||
}
|
|
||||||
|
|
||||||
QString WinRtPackageDeploymentStep::defaultWinDeployQtArguments() const
|
QString WinRtPackageDeploymentStep::defaultWinDeployQtArguments() const
|
||||||
{
|
{
|
||||||
QString args;
|
QString args;
|
||||||
|
@@ -31,6 +31,33 @@
|
|||||||
namespace WinRt {
|
namespace WinRt {
|
||||||
namespace Internal {
|
namespace Internal {
|
||||||
|
|
||||||
|
class WinRtArgumentsAspect : public ProjectExplorer::ProjectConfigurationAspect
|
||||||
|
{
|
||||||
|
Q_OBJECT
|
||||||
|
|
||||||
|
public:
|
||||||
|
WinRtArgumentsAspect();
|
||||||
|
~WinRtArgumentsAspect() override;
|
||||||
|
|
||||||
|
void addToLayout(ProjectExplorer::LayoutBuilder &builder) override;
|
||||||
|
|
||||||
|
void fromMap(const QVariantMap &map) override;
|
||||||
|
void toMap(QVariantMap &map) const override;
|
||||||
|
|
||||||
|
void setValue(const QString &value);
|
||||||
|
QString value() const;
|
||||||
|
|
||||||
|
void setDefaultValue(const QString &value);
|
||||||
|
QString defaultValue() const;
|
||||||
|
|
||||||
|
void restoreDefaultValue();
|
||||||
|
|
||||||
|
private:
|
||||||
|
Utils::FancyLineEdit *m_lineEdit = nullptr;
|
||||||
|
QString m_value;
|
||||||
|
QString m_defaultValue;
|
||||||
|
};
|
||||||
|
|
||||||
class WinRtPackageDeploymentStep : public ProjectExplorer::AbstractProcessStep
|
class WinRtPackageDeploymentStep : public ProjectExplorer::AbstractProcessStep
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
@@ -48,11 +75,10 @@ private:
|
|||||||
void doRun() override;
|
void doRun() override;
|
||||||
bool processSucceeded(int exitCode, QProcess::ExitStatus status) override;
|
bool processSucceeded(int exitCode, QProcess::ExitStatus status) override;
|
||||||
void stdOutput(const QString &line) override;
|
void stdOutput(const QString &line) override;
|
||||||
ProjectExplorer::BuildStepConfigWidget *createConfigWidget() override;
|
|
||||||
|
|
||||||
bool parseIconsAndExecutableFromManifest(QString manifestFileName, QStringList *items, QString *executable);
|
bool parseIconsAndExecutableFromManifest(QString manifestFileName, QStringList *items, QString *executable);
|
||||||
|
|
||||||
ProjectExplorer::BaseStringAspect *m_argsAspect = nullptr;
|
WinRtArgumentsAspect *m_argsAspect = nullptr;
|
||||||
QString m_targetFilePath;
|
QString m_targetFilePath;
|
||||||
QString m_targetDirPath;
|
QString m_targetDirPath;
|
||||||
QString m_executablePathInManifest;
|
QString m_executablePathInManifest;
|
||||||
|
Reference in New Issue
Block a user