Commit 4d2e5a7d authored by hjk's avatar hjk

Debugger: More robust document access in cppExpressionAt

Change-Id: I53658225e001b0568c77f095d18e9452b792c5f9
Reviewed-by: default avatarDavid Schulz <david.schulz@digia.com>
parent 29d0ddf2
......@@ -35,11 +35,12 @@
#include <texteditor/basetexteditor.h>
#include <cpptools/abstracteditorsupport.h>
#include <cpptools/cppprojectfile.h>
#include <cpptools/cppmodelmanagerinterface.h>
#include <cplusplus/ExpressionUnderCursor.h>
#include <cplusplus/Overview.h>
#include <utils/qtcassert.h>
#include <QDebug>
#include <string.h>
......@@ -334,13 +335,14 @@ QString cppExpressionAt(TextEditor::ITextEditor *editor, int pos,
if (!plaintext)
return QString();
QString expr = plaintext->textCursor().selectedText();
QTextCursor tc = plaintext->textCursor();
QString expr = tc.selectedText();
CppModelManagerInterface *modelManager = CppModelManagerInterface::instance();
if (expr.isEmpty() && modelManager) {
QTextCursor tc(plaintext->document());
QTextDocument *doc = plaintext->document();
QTC_ASSERT(doc, return QString());
tc.setPosition(pos);
const QChar ch = editor->textDocument()->characterAt(pos);
const QChar ch = doc->characterAt(pos);
if (ch.isLetterOrNumber() || ch == QLatin1Char('_'))
tc.movePosition(QTextCursor::EndOfWord);
......@@ -350,7 +352,6 @@ QString cppExpressionAt(TextEditor::ITextEditor *editor, int pos,
*column = tc.positionInBlock();
*line = tc.blockNumber();
} else {
const QTextCursor tc = plaintext->textCursor();
*column = tc.positionInBlock();
*line = tc.blockNumber();
}
......
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