From 5cb41883125ba2d4214045754c75b43b79ee29b1 Mon Sep 17 00:00:00 2001 From: Jeremy Wootten Date: Tue, 27 Jun 2023 15:17:33 +0100 Subject: [PATCH 1/2] Stop recreating backup file when closing and stripping trailing space --- src/Services/Document.vala | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/Services/Document.vala b/src/Services/Document.vala index 0ea9df218..09f98fa83 100644 --- a/src/Services/Document.vala +++ b/src/Services/Document.vala @@ -466,6 +466,7 @@ namespace Scratch.Services { if (ret_value) { // Delete backup copy file + loaded = false; // Stops recreating backup when trailing space stripped delete_backup (); doc_closed (); } @@ -1005,7 +1006,7 @@ namespace Scratch.Services { // Backup functions private void create_backup () { - if (!can_write ()) { + if (!can_write () || !loaded) { return; } From c8cc85df5d3d8e8692712021f8005eeed51ee6ef Mon Sep 17 00:00:00 2001 From: Jeremy Wootten Date: Tue, 27 Jun 2023 15:27:10 +0100 Subject: [PATCH 2/2] Use new flag for closing to avoid side-effects --- src/Services/Document.vala | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/Services/Document.vala b/src/Services/Document.vala index 09f98fa83..2f5b89691 100644 --- a/src/Services/Document.vala +++ b/src/Services/Document.vala @@ -130,6 +130,7 @@ namespace Scratch.Services { private ulong onchange_handler_id = 0; // It is used to not mark files as changed on load private bool loaded = false; private bool mounted = true; // Mount state of the file + private bool closing = false; private Mount mount; private Icon locked_icon; @@ -466,7 +467,7 @@ namespace Scratch.Services { if (ret_value) { // Delete backup copy file - loaded = false; // Stops recreating backup when trailing space stripped + closing = true; // Stops recreating backup when trailing space stripped delete_backup (); doc_closed (); } @@ -1006,7 +1007,7 @@ namespace Scratch.Services { // Backup functions private void create_backup () { - if (!can_write () || !loaded) { + if (!can_write () || closing) { return; }