From 7edb110e45b587fc1eb61d742f26d53a5ce1eadd Mon Sep 17 00:00:00 2001
From: Roberto Raggi <roberto.raggi@nokia.com>
Date: Wed, 25 Nov 2009 10:41:11 +0100
Subject: [PATCH] Check for valid paths

Reviewed-By: Christian Kamm <christian.d.kamm@nokia.com>
---
 src/plugins/cppeditor/cppquickfix.cpp | 6 ++----
 1 file changed, 2 insertions(+), 4 deletions(-)

diff --git a/src/plugins/cppeditor/cppquickfix.cpp b/src/plugins/cppeditor/cppquickfix.cpp
index 4974e25591f..5556122f78c 100644
--- a/src/plugins/cppeditor/cppquickfix.cpp
+++ b/src/plugins/cppeditor/cppquickfix.cpp
@@ -275,9 +275,6 @@ public:
 
     virtual int match(const QList<AST *> &path)
     {
-        if (path.size() == 0)
-            return -1;        
-
         // show when we're on the 'if' of an if statement
         int index = path.size() - 1;
         IfStatementAST *ifStatement = path.at(index)->asIfStatement();
@@ -805,7 +802,8 @@ int CPPQuickFixCollector::startCompletion(TextEditor::ITextEditable *editable)
         ASTPath astPath(info.doc);
 
         const QList<AST *> path = astPath(_editor->textCursor());
-        // ### build the list of the quick fix ops by scanning path.
+        if (path.isEmpty())
+            return -1;
 
         QSharedPointer<RewriteLogicalAndOp> rewriteLogicalAndOp(new RewriteLogicalAndOp(info.doc, info.snapshot, _editor));
         QSharedPointer<SplitIfStatementOp> splitIfStatementOp(new SplitIfStatementOp(info.doc, info.snapshot, _editor));
-- 
GitLab