From 478e1e6679b7198b98b8d4f6273a308f3ef24285 Mon Sep 17 00:00:00 2001 From: Jabiertxof Date: Wed, 6 Oct 2021 18:31:50 +0200 Subject: [PATCH] Fix some undo crashes with knots specialy on undo/redo This basicaly discard selection on undo/redo --- src/selection-chemistry.cpp | 6 ++++-- src/ui/dialog/undo-history.cpp | 8 ++++++++ 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/src/selection-chemistry.cpp b/src/selection-chemistry.cpp index 123293d7e4..43e1d21709 100644 --- a/src/selection-chemistry.cpp +++ b/src/selection-chemistry.cpp @@ -1252,7 +1252,8 @@ sp_undo(SPDesktop *desktop, SPDocument *) { // No re/undo while dragging, too dangerous. if (desktop->getCanvas()->is_dragging()) return; - + // we force unselect to avoid knot problems + desktop->selection->clear(); if (!DocumentUndo::undo(desktop->getDocument())) { desktop->messageStack()->flash(Inkscape::WARNING_MESSAGE, _("Nothing to undo.")); } @@ -1263,7 +1264,8 @@ sp_redo(SPDesktop *desktop, SPDocument *) { // No re/undo while dragging, too dangerous. if (desktop->getCanvas()->is_dragging()) return; - + // we force unselect to avoid knot problems + desktop->selection->clear(); if (!DocumentUndo::redo(desktop->getDocument())) { desktop->messageStack()->flash(Inkscape::WARNING_MESSAGE, _("Nothing to redo.")); } diff --git a/src/ui/dialog/undo-history.cpp b/src/ui/dialog/undo-history.cpp index a2e3862601..992c8644ea 100644 --- a/src/ui/dialog/undo-history.cpp +++ b/src/ui/dialog/undo-history.cpp @@ -218,6 +218,10 @@ UndoHistory::_onListSelectionChange() /* If no event is selected in the view, find the right one and select it. This happens whenever * a branch we're currently in is collapsed. */ + SPDesktop* desktop = getDesktop(); + if (desktop) { + desktop->selection->clear(); + } if (!selected) { EventLog::iterator curr_event = _event_log->getCurrEvent(); @@ -325,6 +329,10 @@ UndoHistory::_onExpandEvent(const Gtk::TreeModel::iterator &iter, const Gtk::Tre void UndoHistory::_onCollapseEvent(const Gtk::TreeModel::iterator &iter, const Gtk::TreeModel::Path &/*path*/) { + SPDesktop* desktop = getDesktop(); + if (desktop) { + desktop->selection->clear(); + } // Collapsing a branch we're currently in is equal to stepping to the last event in that branch if ( iter == _event_log->getCurrEvent() ) { EventLog::const_iterator curr_event_parent = _event_log->getCurrEvent(); -- GitLab