forked from qt-creator/qt-creator
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 <daniel.teske@nokia.com> Reviewed-by: Oswald Buddenhagen <oswald.buddenhagen@nokia.com>
This commit is contained in:
@@ -419,7 +419,7 @@ void ProFileEvaluator::Private::initStatics()
|
|||||||
statics.reg_variableName.setPattern(QLatin1String("\\$\\(.*\\)"));
|
statics.reg_variableName.setPattern(QLatin1String("\\$\\(.*\\)"));
|
||||||
statics.reg_variableName.setMinimal(true);
|
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 {
|
static const struct {
|
||||||
const char * const name;
|
const char * const name;
|
||||||
@@ -3119,12 +3119,16 @@ QHash<ProString, ProStringList> *ProFileEvaluator::Private::findValues(
|
|||||||
ProStringList &ProFileEvaluator::Private::valuesRef(const ProString &variableName)
|
ProStringList &ProFileEvaluator::Private::valuesRef(const ProString &variableName)
|
||||||
{
|
{
|
||||||
QHash<ProString, ProStringList>::Iterator it = m_valuemapStack.top().find(variableName);
|
QHash<ProString, ProStringList>::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;
|
return *it;
|
||||||
|
}
|
||||||
for (int i = m_valuemapStack.size() - 1; --i >= 0; ) {
|
for (int i = m_valuemapStack.size() - 1; --i >= 0; ) {
|
||||||
QHash<ProString, ProStringList>::ConstIterator it = m_valuemapStack.at(i).constFind(variableName);
|
QHash<ProString, ProStringList>::ConstIterator it = m_valuemapStack.at(i).constFind(variableName);
|
||||||
if (it != m_valuemapStack.at(i).constEnd()) {
|
if (it != m_valuemapStack.at(i).constEnd()) {
|
||||||
ProStringList &ret = m_valuemapStack.top()[variableName];
|
ProStringList &ret = m_valuemapStack.top()[variableName];
|
||||||
|
if (it->constBegin() != statics.fakeValue.constBegin())
|
||||||
ret = *it;
|
ret = *it;
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user