Core: Make preview work when FOO is both a variable and a prefix

Make the preview of variable "FOO" work in the variable chooser when the
macroexpander also has a prefix "FOO:" defined.

The MacroExpander::isPrefixVariable method is broken in this case: It will
append ':' to the variable name if it is not there already and will thus
return true for both "FOO" and "FOO:". So avoid calling it.

In this case this does not even lead to more look-ups: As the variable chooser
uses the description of the variable as a key, it contains "FOO:<value>" for
the variable name and uses that checks whether "FOO:<value>:" is a prefix variable
or not. That is always false.

Task-number: QTCREATORBUG-20504
Change-Id: I3ea83a4df6d72aac157fa6777106966cc9e9976d
Reviewed-by: Eike Ziller <eike.ziller@qt.io>
This commit is contained in:
Tobias Hunger
2018-06-04 15:09:38 +02:00
parent 2fb270c77f
commit 14a9133abb

View File

@@ -203,9 +203,7 @@ public:
if (role == Qt::ToolTipRole) {
QString description = m_expander->variableDescription(m_variable);
QString value;
if (!m_expander->isPrefixVariable(m_variable))
value = m_expander->value(m_variable).toHtmlEscaped();
const QString value = m_expander->value(m_variable).toHtmlEscaped();
if (!value.isEmpty())
description += QLatin1String("<p>") + VariableChooser::tr("Current Value: %1").arg(value);
return description;