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); });