diff --git a/interfaces/idocumentationcontroller.h b/interfaces/idocumentationcontroller.h --- a/interfaces/idocumentationcontroller.h +++ b/interfaces/idocumentationcontroller.h @@ -45,10 +45,10 @@ /** Return the corresponding documentation instance for a determinate declaration. */ virtual IDocumentation::Ptr documentationForDeclaration(Declaration* declaration) = 0; +public Q_SLOTS: /** Show the documentation specified by @p doc. */ virtual void showDocumentation(const IDocumentation::Ptr& doc) = 0; -public Q_SLOTS: /** Emit signal when the documentation providers list changed. */ virtual void changedDocumentationProviders() = 0; diff --git a/language/duchain/navigation/abstractnavigationcontext.cpp b/language/duchain/navigation/abstractnavigationcontext.cpp --- a/language/duchain/navigation/abstractnavigationcontext.cpp +++ b/language/duchain/navigation/abstractnavigationcontext.cpp @@ -213,7 +213,10 @@ } case NavigationAction::ShowDocumentation: { auto doc = ICore::self()->documentationController()->documentationForDeclaration(action.decl.data()); - ICore::self()->documentationController()->showDocumentation(doc); + // This is used to execute the slot delayed in the event-loop, so crashes are avoided + // which can happen e.g. due to focus change events resulting in tooltip destruction and thus this object + qRegisterMetaType("IDocumentation::Ptr"); + QMetaObject::invokeMethod(ICore::self()->documentationController(), "showDocumentation", Qt::QueuedConnection, Q_ARG(IDocumentation::Ptr, doc)); } break; }