From 0874e23ecde02535c36af16acf77ce2edc7413f7 Mon Sep 17 00:00:00 2001 From: Oliver Hamlet Date: Sat, 20 Feb 2016 15:50:59 +0000 Subject: [PATCH] Fix "You have not sorted..." reappearing The "You have not sorted..." message was reappearing after sorting your load order when no changes were necessary, then switching to another game then back again, because the cancelSort query was reinstating the message. A new discardUnappliedChanges query was added to ensure the change counter is zeroed, and that used where appropriate instead of cancelSort. --- src/gui/handler.cpp | 6 ++++++ src/gui/html/js/events.js | 20 +++++--------------- 2 files changed, 11 insertions(+), 15 deletions(-) diff --git a/src/gui/handler.cpp b/src/gui/handler.cpp index 2764b1a9..f78de6f5 100644 --- a/src/gui/handler.cpp +++ b/src/gui/handler.cpp @@ -180,6 +180,12 @@ namespace loot { callback->Success(""); return true; } + else if (request == "discardUnappliedChanges") { + while (_lootState.hasUnappliedChanges()) + _lootState.decrementUnappliedChangeCounter(); + callback->Success(""); + return true; + } else { // May be a request with arguments. YAML::Node req; diff --git a/src/gui/html/js/events.js b/src/gui/html/js/events.js index 50f9c7bb..51d9f319 100644 --- a/src/gui/html/js/events.js +++ b/src/gui/html/js/events.js @@ -119,9 +119,9 @@ function onSortPlugins() { existingPlugin.isEmpty = plugin.isEmpty; } }); - /* Send cancelSort query to notify that no unapplied sorting changes are - present. Not doing so prevents LOOT's window from closing. */ - loot.query('cancelSort'); + /* Send discardUnappliedChanges query. Not doing so prevents LOOT's window + from closing. */ + loot.query('discardUnappliedChanges'); loot.Dialog.closeProgress(); loot.Dialog.showNotification(loot.l10n.translate('Sorting made no changes to the load order.')); return; @@ -333,18 +333,8 @@ function handleUnappliedChangesClose(change) { if (!result) { return; } - /* Cancel any sorting and close any editors. Cheat by sending a - cancelSort query for as many times as necessary. */ - const queries = []; - let numQueries = 0; - if (!document.getElementById('applySortButton').hidden) { - numQueries += 1; - } - numQueries += document.body.getAttribute('data-editors'); - for (let i = 0; i < numQueries; ++i) { - queries.push(loot.query('cancelSort')); - } - Promise.all(queries).then(() => { + /* Discard any unapplied changes. */ + loot.query('discardUnappliedChanges').then(() => { window.close(); }).catch(handlePromiseError); });