From 323be40b3e14a77d39856674a13bd1ecadacd04b Mon Sep 17 00:00:00 2001 From: Nikolai Kosjar Date: Wed, 27 Nov 2013 15:53:03 +0100 Subject: CppEditor: Fix stack overflow in quick fixes The MoveDeclarationOutOfIf quick fix modified a IfStatementAST in case there were several such ASTs in interface->path(). The resulting AST was invalid (else_statement was pointing to 'this' afterwards), thus the afterwards executed PointerDeclarationFormatter (an ASTVisitor) was not able to finish his visit. The actual problem was that op->pattern in the match() calls was not reset. Task-number: QTCREATORBUG-10919 Change-Id: Ifbcac73e75690321ef45b6d8c2dc32fcea236efa Reviewed-by: Erik Verbruggen --- src/plugins/cppeditor/cppquickfixes.cpp | 13 +++++++++++++ 1 file changed, 13 insertions(+) (limited to 'src/plugins/cppeditor/cppquickfixes.cpp') diff --git a/src/plugins/cppeditor/cppquickfixes.cpp b/src/plugins/cppeditor/cppquickfixes.cpp index 46302c0200..9feaef149a 100644 --- a/src/plugins/cppeditor/cppquickfixes.cpp +++ b/src/plugins/cppeditor/cppquickfixes.cpp @@ -774,6 +774,11 @@ public: setDescription(QApplication::translate("CppTools::QuickFix", "Move Declaration out of Condition")); + reset(); + } + + void reset() + { condition = mk.Condition(); pattern = mk.IfStatement(condition); } @@ -826,6 +831,8 @@ void MoveDeclarationOutOfIf::match(const CppQuickFixInterface &interface, result.append(op); return; } + + op->reset(); } } } @@ -841,7 +848,11 @@ public: { setDescription(QApplication::translate("CppTools::QuickFix", "Move Declaration out of Condition")); + reset(); + } + void reset() + { condition = mk.Condition(); pattern = mk.WhileStatement(condition); } @@ -903,6 +914,8 @@ void MoveDeclarationOutOfWhile::match(const CppQuickFixInterface &interface, result.append(op); return; } + + op->reset(); } } } -- cgit v1.2.1 From a06c5ef1515822b5693e2be24060a77a049cf465 Mon Sep 17 00:00:00 2001 From: Orgad Shaneh Date: Mon, 11 Nov 2013 22:11:14 +0200 Subject: CppEditor: Cleanup quickfixes Change-Id: I19fb785372291f66b756cf5be1fc941870c304c3 Reviewed-by: Nikolai Kosjar --- src/plugins/cppeditor/cppquickfixes.cpp | 14 ++++---------- 1 file changed, 4 insertions(+), 10 deletions(-) (limited to 'src/plugins/cppeditor/cppquickfixes.cpp') diff --git a/src/plugins/cppeditor/cppquickfixes.cpp b/src/plugins/cppeditor/cppquickfixes.cpp index 9feaef149a..0dcb161b8d 100644 --- a/src/plugins/cppeditor/cppquickfixes.cpp +++ b/src/plugins/cppeditor/cppquickfixes.cpp @@ -158,10 +158,8 @@ InsertionLocation insertLocationForMethodDefinition(Symbol *symbol, const bool u = locator.methodDefinition(symbol, useSymbolFinder, fileName); for (int i = 0; i < list.count(); ++i) { InsertionLocation location = list.at(i); - if (location.isValid() && location.fileName() == fileName) { + if (location.isValid() && location.fileName() == fileName) return location; - break; - } } // ...failed, @@ -4769,11 +4767,11 @@ public: ? Qt::Checked : Qt::Unchecked; for (Scope::iterator it = clazz->firstMember(); it != clazz->lastMember(); ++it) { if (const Function *func = (*it)->type()->asFunctionType()) { - if (!func->isVirtual()) + // Filter virtual destructors + if (func->name()->asDestructorNameId()) continue; - // Filter virtual destructors - if (printer.prettyName(func->name()).startsWith(QLatin1Char('~'))) + if (!func->isVirtual()) continue; // Filter OQbject's @@ -4917,16 +4915,12 @@ public: switch (spec) { case InsertionPointLocator::Private: return InsertionPointLocator::PrivateSlot; - break; case InsertionPointLocator::Protected: return InsertionPointLocator::ProtectedSlot; - break; case InsertionPointLocator::Public: return InsertionPointLocator::PublicSlot; - break; default: return spec; - break; } } return spec; -- cgit v1.2.1