From 087021a23cc7d9fa44b57edfb2cc676ee1f09fe7 Mon Sep 17 00:00:00 2001 From: Oswald Buddenhagen Date: Tue, 3 Jul 2012 12:18:47 +0200 Subject: [PATCH] add some future safety detaching an empty vector does not necessarily do anything. on the downsite, as the sentinel value is not empty any more, we need to explicitly clear it out when we meet it. Change-Id: I0f15aa3d421706a5423bf37f3173a807d0d49c53 Reviewed-by: Daniel Teske Reviewed-by: Oswald Buddenhagen --- src/shared/proparser/profileevaluator.cpp | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/src/shared/proparser/profileevaluator.cpp b/src/shared/proparser/profileevaluator.cpp index 3585b17f790..086f28e9eef 100644 --- a/src/shared/proparser/profileevaluator.cpp +++ b/src/shared/proparser/profileevaluator.cpp @@ -419,7 +419,7 @@ void ProFileEvaluator::Private::initStatics() statics.reg_variableName.setPattern(QLatin1String("\\$\\(.*\\)")); statics.reg_variableName.setMinimal(true); - statics.fakeValue.detach(); // It has to have a unique begin() value + statics.fakeValue = ProStringList(ProString("_FAKE_")); // It has to have a unique begin() value static const struct { const char * const name; @@ -3119,13 +3119,17 @@ QHash *ProFileEvaluator::Private::findValues( ProStringList &ProFileEvaluator::Private::valuesRef(const ProString &variableName) { QHash::Iterator it = m_valuemapStack.top().find(variableName); - if (it != m_valuemapStack.top().end()) + if (it != m_valuemapStack.top().end()) { + if (it->constBegin() == statics.fakeValue.constBegin()) + it->clear(); return *it; + } for (int i = m_valuemapStack.size() - 1; --i >= 0; ) { QHash::ConstIterator it = m_valuemapStack.at(i).constFind(variableName); if (it != m_valuemapStack.at(i).constEnd()) { ProStringList &ret = m_valuemapStack.top()[variableName]; - ret = *it; + if (it->constBegin() != statics.fakeValue.constBegin()) + ret = *it; return ret; } }