fix kate crash

This commit is contained in:
Levi Neely 2026-07-15 17:54:17 +02:00
parent 455d9c9190
commit d5e27f1c82
2 changed files with 8 additions and 5 deletions

View File

@ -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<KTextEditor::InlineNoteInterface *>(m_view);
if (iface)
iface->unregisterInlineNoteProvider(this);
auto *iface = dynamic_cast<KTextEditor::InlineNoteInterface *>(m_view);
if (iface)
iface->unregisterInlineNoteProvider(this);
#endif
}
}
// --- InlineNoteProvider interface ---

View File

@ -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