Index: kdevplatform/shell/textdocument.cpp =================================================================== --- kdevplatform/shell/textdocument.cpp +++ kdevplatform/shell/textdocument.cpp @@ -231,10 +231,14 @@ IDocument::DocumentState state = IDocument::Clean; QString encoding; bool loaded = false; - // we want to remove the added stuff when the menu hides - QMenu* addedContextMenu = nullptr; + // we want to remove the added stuff when the menu hides. + // This has to be a static instance because multiple views + // can share the same context menu instance. + static QMenu* addedContextMenu; }; +QMenu* TextDocumentPrivate::addedContextMenu = nullptr; + class TextViewPrivate { public: