From 9296a7fb9ce0c57fe7033fb53e31da7a0e88f889 Mon Sep 17 00:00:00 2001 From: David Schulz Date: Mon, 5 Feb 2024 05:32:14 +0100 Subject: [PATCH] TextEditor: fix crash on activating bookmark in deleted file since 23908b283e429a65d937231d59375c72ac1b62f3 bookmarks are opened on double click. But double click also emits an activated. and both signals are connected to gotoBookmark, so this slot got triggered twice. This is problematic when the bookmark is not reachable anymore since the first execution of gotoBookmark deletes unreachable bookmarks, and the second execution has only a nullptr and passes it to functions not checking this pointer. Fixes: QTCREATORBUG-30283 Change-Id: Ia57d0469840d467af31fa5c89745c2ad33aa7e3f Reviewed-by: Xavier BESSON (Personal) Reviewed-by: Christian Stenger --- src/plugins/texteditor/bookmarkmanager.cpp | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/plugins/texteditor/bookmarkmanager.cpp b/src/plugins/texteditor/bookmarkmanager.cpp index ae21a75be88..2e95f7213c2 100644 --- a/src/plugins/texteditor/bookmarkmanager.cpp +++ b/src/plugins/texteditor/bookmarkmanager.cpp @@ -306,9 +306,10 @@ void BookmarkView::removeAll() void BookmarkView::gotoBookmark(const QModelIndex &index) { - Bookmark *bk = m_manager->bookmarkForIndex(index); - if (!m_manager->gotoBookmark(bk)) - m_manager->deleteBookmark(bk); + if (Bookmark *bk = m_manager->bookmarkForIndex(index)) { + if (!m_manager->gotoBookmark(bk)) + m_manager->deleteBookmark(bk); + } } ////