From 9726f0eec6b984c7673f91fa372f776fdab4e639 Mon Sep 17 00:00:00 2001 From: vsonnier Date: Mon, 6 Mar 2017 19:51:27 +0100 Subject: [PATCH] Bookmarks: no need to Delete a tree element when the next steps will take care of it --- src/forms/Bookmark/BookmarkView.cpp | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/src/forms/Bookmark/BookmarkView.cpp b/src/forms/Bookmark/BookmarkView.cpp index bbf5e05..fafd0a5 100644 --- a/src/forms/Bookmark/BookmarkView.cpp +++ b/src/forms/Bookmark/BookmarkView.cpp @@ -175,14 +175,14 @@ void BookmarkView::onUpdateTimer( wxTimerEvent& /* event */ ) { } if (doUpdateActive.load()) { doUpdateActiveList(); - doUpdateActive.store(false); } if (doUpdateBookmarks.load()) { + wxTreeItemId bmSel = refreshBookmarks(); if (bmSel) { m_treeView->SelectItem(bmSel); - } + } doUpdateBookmarks.store(false); } } @@ -1226,9 +1226,11 @@ void BookmarkView::onActivateRecent( wxCommandEvent& /* event */ ) { if (curSel && curSel->type == TreeViewItem::TREEVIEW_ITEM_TYPE_RECENT) { BookmarkEntryPtr bookmarkEntToActivate = curSel->bookmarkEnt; - m_treeView->Delete(m_treeView->GetSelection()); - + + //let removeRecent() + activateBookmark() refresh the tree + //and delete the recent node properly... wxGetApp().getBookmarkMgr().removeRecent(bookmarkEntToActivate); + activateBookmark(bookmarkEntToActivate); } } @@ -1243,7 +1245,9 @@ void BookmarkView::onRemoveRecent ( wxCommandEvent& /* event */ ) { if (curSel && curSel->type == TreeViewItem::TREEVIEW_ITEM_TYPE_RECENT) { BookmarkEntryPtr bookmarkEntToRemove = curSel->bookmarkEnt; - m_treeView->Delete(m_treeView->GetSelection()); + + //let removeRecent() + updateActiveList() refresh the tree + //and delete the recent node properly... wxGetApp().getBookmarkMgr().removeRecent(bookmarkEntToRemove); wxGetApp().getBookmarkMgr().updateActiveList(); } @@ -1442,7 +1446,6 @@ void BookmarkView::onTreeEndDrag( wxTreeEvent& event ) { doBookmarkActive(tvi->groupName, dragItem->demod); } else if (dragItem && dragItem->type == TreeViewItem::TREEVIEW_ITEM_TYPE_RECENT) { // Recent -> Group Item doBookmarkRecent(tvi->groupName, dragItem->bookmarkEnt); - m_treeView->Delete(dragItemId); } else if (dragItem && dragItem->type == TreeViewItem::TREEVIEW_ITEM_TYPE_BOOKMARK) { // Bookmark -> Group Item doMoveBookmark(dragItem->bookmarkEnt, tvi->groupName);