summaryrefslogtreecommitdiff
path: root/src/plugins
diff options
context:
space:
mode:
authorThorbjørn Lindeijer <thorbjorn.lindeijer@nokia.com>2010-04-16 12:26:31 +0200
committerThorbjørn Lindeijer <thorbjorn.lindeijer@nokia.com>2010-04-16 12:29:22 +0200
commit2128669052921371684004390297e0864b8dd704 (patch)
tree72ad0806196af7b4fc132c247c9fb9905dc8ead4 /src/plugins
parentc57e2eaff4db260afca5618edbb382b370004a7d (diff)
downloadqt-creator-2128669052921371684004390297e0864b8dd704.tar.gz
Fixed possible infinite loop when searching in text editor
Caused by uninitialized variable and failure to check for the case where nothing is found. Done-with: mae
Diffstat (limited to 'src/plugins')
-rw-r--r--src/plugins/find/basetextfind.cpp7
1 files changed, 6 insertions, 1 deletions
diff --git a/src/plugins/find/basetextfind.cpp b/src/plugins/find/basetextfind.cpp
index 72dde1ae68..37211b5a55 100644
--- a/src/plugins/find/basetextfind.cpp
+++ b/src/plugins/find/basetextfind.cpp
@@ -38,11 +38,13 @@ using namespace Find;
BaseTextFind::BaseTextFind(QTextEdit *editor)
: m_editor(editor), m_incrementalStartPos(-1)
+ , m_findScopeVerticalBlockSelection(0)
{
}
BaseTextFind::BaseTextFind(QPlainTextEdit *editor)
: m_plaineditor(editor), m_incrementalStartPos(-1)
+ , m_findScopeVerticalBlockSelection(0)
{
}
@@ -280,6 +282,9 @@ bool BaseTextFind::find(const QString &txt,
QTextCursor BaseTextFind::findOne(const QRegExp &expr, const QTextCursor &from, QTextDocument::FindFlags options) const
{
QTextCursor candidate = document()->find(expr, from, options);
+ if (candidate.isNull())
+ return candidate;
+
if (!m_findScopeVerticalBlockSelection)
return candidate;
forever {
@@ -311,7 +316,7 @@ void BaseTextFind::defineFindScope()
if (cursor.hasSelection() && cursor.block() != cursor.document()->findBlock(cursor.anchor())) {
m_findScopeStart = QTextCursor(document()->docHandle(), qMax(0, cursor.selectionStart()-1));
m_findScopeEnd = QTextCursor(document()->docHandle(), cursor.selectionEnd());
- m_findScopeVerticalBlockSelection = false;
+ m_findScopeVerticalBlockSelection = 0;
int verticalBlockSelection = 0;
if (m_plaineditor && m_plaineditor->metaObject()->indexOfProperty("verticalBlockSelection") >= 0)