Commit df8fc5a9 authored by hjk's avatar hjk
Browse files

debugger: restrict accepted expressions in automatci tooltips to simple

identifiers.
parent 15c7e5b3
...@@ -3179,6 +3179,25 @@ void GdbEngine::setToolTipExpression(const QPoint &mousePos, ...@@ -3179,6 +3179,25 @@ void GdbEngine::setToolTipExpression(const QPoint &mousePos,
m_toolTipPos = mousePos; m_toolTipPos = mousePos;
int line, column; int line, column;
QString exp = cppExpressionAt(editor, cursorPos, &line, &column); QString exp = cppExpressionAt(editor, cursorPos, &line, &column);
// Extract the first identifier, everything else is considered
// too dangerous.
int pos1 = 0, pos2 = exp.size();
bool inId = false;
for (int i = 0; i != exp.size(); ++i) {
const QChar c = exp.at(i);
const bool isIdChar = c.isLetterOrNumber() || c.unicode() == '_';
if (inId && !isIdChar) {
pos2 = i;
break;
}
if (!inId && isIdChar) {
inId = true;
pos1 = i;
}
}
exp = exp.mid(pos1, pos2 - pos1);
if (!exp.isEmpty() && exp == m_toolTipExpression) { if (!exp.isEmpty() && exp == m_toolTipExpression) {
showToolTip(); showToolTip();
return; return;
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment