From 61e590a9716bcbb9621ed9f82452b3590a783c91 Mon Sep 17 00:00:00 2001 From: Tobias Hunger Date: Tue, 15 Sep 2015 15:34:26 +0200 Subject: [PATCH] JsonWizard: Expand repeatedly when filling out templates This makes macros work that expand to more macros. Change-Id: I44770fb59cec6cd80606cd341a92938c50e9e1fd Reviewed-by: Orgad Shaneh --- .../jsonwizard/jsonwizardfilegenerator.cpp | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) diff --git a/src/plugins/projectexplorer/jsonwizard/jsonwizardfilegenerator.cpp b/src/plugins/projectexplorer/jsonwizard/jsonwizardfilegenerator.cpp index 9eeed19cef3..f2822ba859c 100644 --- a/src/plugins/projectexplorer/jsonwizard/jsonwizardfilegenerator.cpp +++ b/src/plugins/projectexplorer/jsonwizard/jsonwizardfilegenerator.cpp @@ -56,16 +56,24 @@ static QString processTextFileContents(Utils::MacroExpander *expander, if (input.isEmpty()) return input; - QString tmp; - if (!customWizardPreprocess(expander->expand(input), &tmp, errorMessage)) + // Recursively expand macros: + QString in = input; + QString oldIn; + for (int i = 0; i < 5 && in != oldIn; ++i) { + oldIn = in; + in = expander->expand(oldIn); + } + + QString out; + if (!customWizardPreprocess(in, &out, errorMessage)) return QString(); // Expand \n, \t and handle line continuation: QString result; - result.reserve(tmp.count()); + result.reserve(out.count()); bool isEscaped = false; - for (int i = 0; i < tmp.count(); ++i) { - const QChar c = tmp.at(i); + for (int i = 0; i < out.count(); ++i) { + const QChar c = out.at(i); if (isEscaped) { if (c == QLatin1Char('n'))