Bookmarks: no need to Delete a tree element when the next steps will take care of it

This commit is contained in:
vsonnier 2017-03-06 19:51:27 +01:00
parent 925203b4a5
commit 9726f0eec6

View File

@ -175,14 +175,14 @@ void BookmarkView::onUpdateTimer( wxTimerEvent& /* event */ ) {
} }
if (doUpdateActive.load()) { if (doUpdateActive.load()) {
doUpdateActiveList(); doUpdateActiveList();
doUpdateActive.store(false); doUpdateActive.store(false);
} }
if (doUpdateBookmarks.load()) { if (doUpdateBookmarks.load()) {
wxTreeItemId bmSel = refreshBookmarks(); wxTreeItemId bmSel = refreshBookmarks();
if (bmSel) { if (bmSel) {
m_treeView->SelectItem(bmSel); m_treeView->SelectItem(bmSel);
} }
doUpdateBookmarks.store(false); doUpdateBookmarks.store(false);
} }
} }
@ -1226,9 +1226,11 @@ void BookmarkView::onActivateRecent( wxCommandEvent& /* event */ ) {
if (curSel && curSel->type == TreeViewItem::TREEVIEW_ITEM_TYPE_RECENT) { if (curSel && curSel->type == TreeViewItem::TREEVIEW_ITEM_TYPE_RECENT) {
BookmarkEntryPtr bookmarkEntToActivate = curSel->bookmarkEnt; 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); wxGetApp().getBookmarkMgr().removeRecent(bookmarkEntToActivate);
activateBookmark(bookmarkEntToActivate); activateBookmark(bookmarkEntToActivate);
} }
} }
@ -1243,7 +1245,9 @@ void BookmarkView::onRemoveRecent ( wxCommandEvent& /* event */ ) {
if (curSel && curSel->type == TreeViewItem::TREEVIEW_ITEM_TYPE_RECENT) { if (curSel && curSel->type == TreeViewItem::TREEVIEW_ITEM_TYPE_RECENT) {
BookmarkEntryPtr bookmarkEntToRemove = curSel->bookmarkEnt; 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().removeRecent(bookmarkEntToRemove);
wxGetApp().getBookmarkMgr().updateActiveList(); wxGetApp().getBookmarkMgr().updateActiveList();
} }
@ -1442,7 +1446,6 @@ void BookmarkView::onTreeEndDrag( wxTreeEvent& event ) {
doBookmarkActive(tvi->groupName, dragItem->demod); doBookmarkActive(tvi->groupName, dragItem->demod);
} else if (dragItem && dragItem->type == TreeViewItem::TREEVIEW_ITEM_TYPE_RECENT) { // Recent -> Group Item } else if (dragItem && dragItem->type == TreeViewItem::TREEVIEW_ITEM_TYPE_RECENT) { // Recent -> Group Item
doBookmarkRecent(tvi->groupName, dragItem->bookmarkEnt); doBookmarkRecent(tvi->groupName, dragItem->bookmarkEnt);
m_treeView->Delete(dragItemId); m_treeView->Delete(dragItemId);
} else if (dragItem && dragItem->type == TreeViewItem::TREEVIEW_ITEM_TYPE_BOOKMARK) { // Bookmark -> Group Item } else if (dragItem && dragItem->type == TreeViewItem::TREEVIEW_ITEM_TYPE_BOOKMARK) { // Bookmark -> Group Item
doMoveBookmark(dragItem->bookmarkEnt, tvi->groupName); doMoveBookmark(dragItem->bookmarkEnt, tvi->groupName);