diff --git a/src/plugins/cppeditor/cppquickfixassistant.cpp b/src/plugins/cppeditor/cppquickfixassistant.cpp index cbf78296bc6..474144e9687 100644 --- a/src/plugins/cppeditor/cppquickfixassistant.cpp +++ b/src/plugins/cppeditor/cppquickfixassistant.cpp @@ -57,8 +57,6 @@ class CppQuickFixAssistProcessor : public IAssistProcessor { QSharedPointer assistInterface(interface); auto cppInterface = assistInterface.staticCast(); - if (cppInterface->path().isEmpty()) - return nullptr; QuickFixOperations quickFixes; for (CppQuickFixFactory *factory : CppQuickFixFactory::cppQuickFixFactories()) diff --git a/src/plugins/cppeditor/cppquickfixes.cpp b/src/plugins/cppeditor/cppquickfixes.cpp index f0d205215af..f1a2d78b0ed 100644 --- a/src/plugins/cppeditor/cppquickfixes.cpp +++ b/src/plugins/cppeditor/cppquickfixes.cpp @@ -750,6 +750,8 @@ void InverseLogicalComparison::match(const CppQuickFixInterface &interface, CppRefactoringFilePtr file = interface.currentFile(); const QList &path = interface.path(); + if (path.isEmpty()) + return; int index = path.size() - 1; BinaryExpressionAST *binary = path.at(index)->asBinaryExpression(); if (!binary) @@ -831,6 +833,8 @@ private: void FlipLogicalOperands::match(const CppQuickFixInterface &interface, QuickFixOperations &result) { const QList &path = interface.path(); + if (path.isEmpty()) + return; CppRefactoringFilePtr file = interface.currentFile(); int index = path.size() - 1; @@ -1098,6 +1102,8 @@ private: void AddBracesToIf::match(const CppQuickFixInterface &interface, QuickFixOperations &result) { const QList &path = interface.path(); + if (path.isEmpty()) + return; // show when we're on the 'if' of an if statement int index = path.size() - 1; @@ -7520,6 +7526,8 @@ private: void EscapeStringLiteral::match(const CppQuickFixInterface &interface, QuickFixOperations &result) { const QList &path = interface.path(); + if (path.isEmpty()) + return; AST * const lastAst = path.last(); ExpressionAST *literal = lastAst->asStringLiteral();