From d5e27f1c826fa412aa283585ace02320ae4340e4 Mon Sep 17 00:00:00 2001 From: Levi Neely <141506390+lneely@users.noreply.github.com> Date: Wed, 15 Jul 2026 17:54:17 +0200 Subject: [PATCH] fix kate crash --- kate/ollie_ghost.cpp | 11 +++++++---- kate/ollie_kate.cpp | 2 +- 2 files changed, 8 insertions(+), 5 deletions(-) diff --git a/kate/ollie_ghost.cpp b/kate/ollie_ghost.cpp index f54f9e1..3d655d1 100644 --- a/kate/ollie_ghost.cpp +++ b/kate/ollie_ghost.cpp @@ -102,6 +102,7 @@ OllieGhostProvider::OllieGhostProvider(KTextEditor::View *view, QDBusInterface * this, &OllieGhostProvider::onCursorPositionChanged); connect(view->document(), &KTextEditor::Document::textChanged, this, &OllieGhostProvider::onTextChanged); + connect(view, &QObject::destroyed, this, [this]() { m_view = nullptr; }); #if KTEXTEDITOR_VERSION_MAJOR >= 6 view->registerInlineNoteProvider(this); @@ -120,13 +121,15 @@ OllieGhostProvider::~OllieGhostProvider() // m_overlay is parented to the view widget and may already be destroyed // by Qt's child cleanup before we get here — just null it out. m_overlay = nullptr; + if (m_view) { #if KTEXTEDITOR_VERSION_MAJOR >= 6 - m_view->unregisterInlineNoteProvider(this); + m_view->unregisterInlineNoteProvider(this); #else - auto *iface = dynamic_cast(m_view); - if (iface) - iface->unregisterInlineNoteProvider(this); + auto *iface = dynamic_cast(m_view); + if (iface) + iface->unregisterInlineNoteProvider(this); #endif + } } // --- InlineNoteProvider interface --- diff --git a/kate/ollie_kate.cpp b/kate/ollie_kate.cpp index feeba98..55e0f49 100644 --- a/kate/ollie_kate.cpp +++ b/kate/ollie_kate.cpp @@ -689,7 +689,7 @@ void OllieKateView::setupGhostProvider() m_ghost = nullptr; // Create new ghost provider for the active view - m_ghost = new OllieGhostProvider(view, m_iface, m_plugin, view); + m_ghost = new OllieGhostProvider(view, m_iface, m_plugin, this); m_ghost->setEnabled(m_plugin->completionEnabled()); // Install event filter on the view widget for Tab interception