Macro expander: Do not use RunConfiguration::runnable()

... to get the current executable. That leads to an infinite loop if the
argument or working directory fields reference the
%{CurrentRun:Executable:Path} variable, as these fields also get
evaluated in RunConfiguration::runnable().

Fixes: QTCREATORBUG-18317
Change-Id: Ic249f8ff78d170110947e370045144817b179341
Reviewed-by: hjk <hjk@qt.io>
This commit is contained in:
Christian Kandeler
2019-02-27 14:34:18 +01:00
parent 86e16c9e14
commit f6c276daf0

View File

@@ -44,6 +44,7 @@
#include "projectexplorersettingspage.h"
#include "projectmanager.h"
#include "removetaskhandler.h"
#include "runconfigurationaspects.h"
#include "kitfeatureprovider.h"
#include "kitmanager.h"
#include "kitoptionspage.h"
@@ -1586,8 +1587,14 @@ bool ProjectExplorerPlugin::initialize(const QStringList &arguments, QString *er
tr("The currently active run configuration's executable (if applicable)."),
[]() -> QString {
if (Target *target = activeTarget()) {
if (RunConfiguration *rc = target->activeRunConfiguration())
return rc->runnable().executable;
if (RunConfiguration *rc = target->activeRunConfiguration()) {
// TODO: This duplicates code and is not always correct, but see
// QTCREATORBUG-18317.
// Solution: Re-introduce RunConfiguration::executable()?
if (auto executableAspect = rc->aspect<ExecutableAspect>())
return executableAspect->executable().toString();
return QString();
}
}
return QString();
});