From f85f24e847d285840883b417d3c0e9337cfaaaaa Mon Sep 17 00:00:00 2001 From: Joshua Ogunyinka Date: Sat, 28 Aug 2021 08:54:00 +0400 Subject: [PATCH] fixed restoring grid preference on undo/redo (fix #2872) --- src/app/cmd/set_grid_bounds.cpp | 7 +++++++ src/app/commands/cmd_grid.cpp | 1 - 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/src/app/cmd/set_grid_bounds.cpp b/src/app/cmd/set_grid_bounds.cpp index 63fc86fea..8011dca50 100644 --- a/src/app/cmd/set_grid_bounds.cpp +++ b/src/app/cmd/set_grid_bounds.cpp @@ -13,6 +13,7 @@ #include "app/doc.h" #include "app/doc_event.h" #include "app/doc_observer.h" +#include "app/pref/preferences.h" #include "doc/sprite.h" namespace app { @@ -31,6 +32,9 @@ void SetGridBounds::onExecute() { Sprite* spr = sprite(); spr->setGridBounds(m_newBounds); + Doc* doc = static_cast(spr->document()); + auto& docPref = Preferences::instance().document(doc); + docPref.grid.bounds(m_newBounds); spr->incrementVersion(); } @@ -38,6 +42,9 @@ void SetGridBounds::onUndo() { Sprite* spr = sprite(); spr->setGridBounds(m_oldBounds); + Doc* doc = static_cast(spr->document()); + auto& docPref = Preferences::instance().document(doc); + docPref.grid.bounds(m_oldBounds); spr->incrementVersion(); } diff --git a/src/app/commands/cmd_grid.cpp b/src/app/commands/cmd_grid.cpp index ee2f00e8c..4dff7bda3 100644 --- a/src/app/commands/cmd_grid.cpp +++ b/src/app/commands/cmd_grid.cpp @@ -131,7 +131,6 @@ void GridSettingsCommand::onExecute(Context* context) tx.commit(); auto& docPref = Preferences::instance().document(site.document()); - docPref.grid.bounds(bounds); if (!docPref.show.grid()) // Make grid visible docPref.show.grid(true); }