summaryrefslogtreecommitdiff
path: root/src/libs
diff options
context:
space:
mode:
authorhjk <hjk121@nokiamail.com>2014-11-05 12:31:03 +0100
committerhjk <hjk121@nokiamail.com>2014-11-05 14:01:41 +0100
commit6d28a58e94faaed18d93aff1dcb47cbc72aee97e (patch)
tree5f9232cf51e4041473d83767578e9a45784c9867 /src/libs
parent71bf6cf03ebbed2901626394d049740a2641e6c5 (diff)
downloadqt-creator-6d28a58e94faaed18d93aff1dcb47cbc72aee97e.tar.gz
Nicer error reporting for infinite recursion
Change-Id: Idf0adfe70f46c7062ccdc0cbea309f47c5fca89e Reviewed-by: Tobias Hunger <tobias.hunger@theqtcompany.com> Reviewed-by: Eike Ziller <eike.ziller@theqtcompany.com>
Diffstat (limited to 'src/libs')
-rw-r--r--src/libs/utils/macroexpander.cpp15
1 files changed, 13 insertions, 2 deletions
diff --git a/src/libs/utils/macroexpander.cpp b/src/libs/utils/macroexpander.cpp
index 067bd97dcc..74fdab9f53 100644
--- a/src/libs/utils/macroexpander.cpp
+++ b/src/libs/utils/macroexpander.cpp
@@ -50,7 +50,9 @@ const char kFileBaseNamePostfix[] = ":FileBaseName";
class MacroExpanderPrivate : public AbstractMacroExpander
{
public:
- MacroExpanderPrivate() : m_accumulating(false), m_lockDepth(0) {}
+ MacroExpanderPrivate()
+ : m_accumulating(false), m_aborted(false), m_lockDepth(0)
+ {}
bool resolveMacro(const QString &name, QString *ret)
{
@@ -110,6 +112,7 @@ public:
QVector<MacroExpander *> m_subExpanders; // Not owned
bool m_accumulating;
+ bool m_aborted;
int m_lockDepth;
};
@@ -264,8 +267,13 @@ QString MacroExpander::value(const QByteArray &variable, bool *found) const
*/
QString MacroExpander::expand(const QString &stringWithVariables) const
{
- if (d->m_lockDepth > 3) // Limit recursion.
+ if (d->m_lockDepth == 0)
+ d->m_aborted = false;
+
+ if (d->m_lockDepth > 3) { // Limit recursion.
+ d->m_aborted = true;
return QString();
+ }
++d->m_lockDepth;
@@ -274,6 +282,9 @@ QString MacroExpander::expand(const QString &stringWithVariables) const
--d->m_lockDepth;
+ if (d->m_lockDepth == 0 && d->m_aborted)
+ return tr("Infinite recursion error") + QLatin1String(": ") + stringWithVariables;
+
return res;
}