forked from qt-creator/qt-creator
ProjectExplorer: Fix duplicate macroExpander
An AspectContainer already has a macroExpander so we use that mechanism as the manual handling was error prone. Change-Id: Id0787fcc83f8192ab4402b43290e7bfeca4f13f1 Reviewed-by: David Schulz <david.schulz@qt.io>
This commit is contained in:
@@ -148,6 +148,8 @@ RunConfiguration::RunConfiguration(Target *target, Utils::Id id)
|
||||
forceDisplayNameSerialization();
|
||||
connect(target, &Target::parsingFinished, this, &RunConfiguration::update);
|
||||
|
||||
setMacroExpander(&m_expander);
|
||||
|
||||
m_expander.setDisplayName(Tr::tr("Run Settings"));
|
||||
m_expander.setAccumulating(true);
|
||||
m_expander.registerSubProvider([target] {
|
||||
|
@@ -172,8 +172,6 @@ public:
|
||||
|
||||
void update();
|
||||
|
||||
const Utils::MacroExpander *macroExpander() const { return &m_expander; }
|
||||
|
||||
virtual RunConfiguration *clone(Target *parent);
|
||||
|
||||
protected:
|
||||
|
@@ -19,8 +19,8 @@
|
||||
#include <utils/fancylineedit.h>
|
||||
#include <utils/layoutbuilder.h>
|
||||
#include <utils/pathchooser.h>
|
||||
#include <utils/qtcprocess.h>
|
||||
#include <utils/qtcassert.h>
|
||||
#include <utils/qtcprocess.h>
|
||||
#include <utils/utilsicons.h>
|
||||
|
||||
#include <QCheckBox>
|
||||
@@ -162,11 +162,6 @@ WorkingDirectoryAspect::WorkingDirectoryAspect(AspectContainer *container)
|
||||
setSettingsKey("RunConfiguration.WorkingDirectory");
|
||||
}
|
||||
|
||||
void WorkingDirectoryAspect::setMacroExpander(const MacroExpander *expander)
|
||||
{
|
||||
m_macroExpander = expander;
|
||||
}
|
||||
|
||||
void WorkingDirectoryAspect::setEnvironment(EnvironmentAspect *envAspect)
|
||||
{
|
||||
m_envAspect = envAspect;
|
||||
@@ -179,8 +174,8 @@ void WorkingDirectoryAspect::addToLayoutImpl(Layout &builder)
|
||||
{
|
||||
QTC_CHECK(!m_chooser);
|
||||
m_chooser = new PathChooser;
|
||||
if (QTC_GUARD(m_macroExpander))
|
||||
m_chooser->setMacroExpander(m_macroExpander);
|
||||
if (QTC_GUARD(macroExpander()))
|
||||
m_chooser->setMacroExpander(macroExpander());
|
||||
m_chooser->setHistoryCompleter(settingsKey());
|
||||
m_chooser->setExpectedKind(Utils::PathChooser::Directory);
|
||||
m_chooser->setPromptDialogTitle(Tr::tr("Select Working Directory"));
|
||||
@@ -254,8 +249,8 @@ FilePath WorkingDirectoryAspect::workingDirectory() const
|
||||
const Environment env = m_envAspect ? m_envAspect->environment()
|
||||
: Environment::systemEnvironment();
|
||||
QString workingDir = m_workingDirectory.path();
|
||||
if (m_macroExpander)
|
||||
workingDir = m_macroExpander->expandProcessArgs(workingDir);
|
||||
if (auto expander = macroExpander())
|
||||
workingDir = expander->expandProcessArgs(workingDir);
|
||||
|
||||
QString res = workingDir.isEmpty() ? QString() : QDir::cleanPath(env.expandVariables(workingDir));
|
||||
|
||||
|
@@ -69,7 +69,6 @@ public:
|
||||
Utils::FilePath unexpandedWorkingDirectory() const;
|
||||
void setDefaultWorkingDirectory(const Utils::FilePath &defaultWorkingDirectory);
|
||||
Utils::PathChooser *pathChooser() const;
|
||||
void setMacroExpander(const Utils::MacroExpander *expander);
|
||||
void setEnvironment(EnvironmentAspect *envAspect);
|
||||
|
||||
private:
|
||||
@@ -83,7 +82,6 @@ private:
|
||||
Utils::FilePath m_defaultWorkingDirectory;
|
||||
QPointer<Utils::PathChooser> m_chooser;
|
||||
QPointer<QToolButton> m_resetButton;
|
||||
const Utils::MacroExpander *m_macroExpander = nullptr;
|
||||
};
|
||||
|
||||
class PROJECTEXPLORER_EXPORT ArgumentsAspect : public Utils::BaseAspect
|
||||
|
Reference in New Issue
Block a user