[utilities/krusader] app/BookMan: BookMan: Solve a crash when adding a bookmark to a new folder

Toni Asensi Esteve <[email protected]>
Newsgroups gmane.comp.kde.cvs
Message-ID <[email protected]>
Git commit 1260116f30f00a0cd5adbc65333b3eea5a88e050 by Toni Asensi Esteve.
Committed on 16/08/2026 at 22:14.
Pushed by asensi into branch 'master'.

BookMan: Solve a crash when adding a bookmark to a new folder

FIXED: [ 520538 ] Krusader - crash when adding bookmark to a new folder
BUG: 520538

Revision: https://invent.kde.org/utilities/krusader/-/merge_requests/193

M  +14   -0    app/BookMan/krbookmarkhandler.cpp

https://invent.kde.org/utilities/krusader/-/commit/1260116f30f00a0cd5adbc65333b3eea5a88e050

diff --git a/app/BookMan/krbookmarkhandler.cpp b/app/BookMan/krbookmarkhandler.cpp
index c5b71953a..236b99032 100644
--- a/app/BookMan/krbookmarkhandler.cpp
+++ b/app/BookMan/krbookmarkhandler.cpp
@@ -99,12 +99,26 @@ KrBookmarkHandler::~KrBookmarkHandler()
 
 void KrBookmarkHandler::bookmarkCurrent(QUrl url)
 {
+    // Disconnect the `KBookmarkManager::changed` signal before
+    // the modal dialog is opened. That way, `importFromFile()`
+    // is not automatically executed while the modal dialog is open,
+    // e.g. if the user presses the "New Folder" button (which causes
+    // an `exportToFile()` execution) that does not cause problems
+    disconnect(manager, &KBookmarkManager::changed,
+               this, &KrBookmarkHandler::bookmarksChanged);
+
     QPointer<KrAddBookmarkDlg> dlg = new KrAddBookmarkDlg(_mainWindow->widget(), std::move(url));
     if (dlg->exec() == QDialog::Accepted) {
         KrBookmark *bm = new KrBookmark(dlg->name(), dlg->url(), _collection);
         addBookmark(bm, dlg->folder());
     }
     delete dlg;
+
+    // Reconnect the `KBookmarkManager::changed` signal, now that the
+    // modal dialog is closed and the KrBookmark pointers from the dialog
+    // are no longer used
+    connect(manager, &KBookmarkManager::changed,
+            this, &KrBookmarkHandler::bookmarksChanged);
 }
 
 void KrBookmarkHandler::addBookmark(KrBookmark *bm, KrBookmark *folder)
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.