Filter memory bugfixes.

This commit is contained in:
WrinklyNinja
2014-08-17 16:26:07 +01:00
parent 0d87e911c9
commit 1ce4ba2bf2
2 changed files with 27 additions and 25 deletions
+17 -8
View File
@@ -125,16 +125,21 @@ function getConflictingPluginsFromFilter() {
});
return loot.query(request).then(function(result){
result = JSON.parse(result);
for (var key in result.crcs) {
for (var i = 0; i < loot.game.plugins.length; ++i) {
if (loot.game.plugins[i].name == key) {
loot.game.plugins[i].crc = result.crcs[key];
break;
if (result) {
result = JSON.parse(result);
for (var key in result.crcs) {
for (var i = 0; i < loot.game.plugins.length; ++i) {
if (loot.game.plugins[i].name == key) {
loot.game.plugins[i].crc = result.crcs[key];
break;
}
}
}
if (result.conflicts) {
return result.conflicts;
}
}
return result.conflicts;
return [];
}).catch(processCefError);
}
}
@@ -780,7 +785,11 @@ function setupEventHandlers() {
/*Set up filter value and CSS setting storage read/write handlers.*/
elements = document.getElementById('filters').getElementsByTagName('input');
for (var i = 0; i < elements.length; ++i) {
elements[i].addEventListener('input', saveFilterState, false);
if (elements[i].type == 'text') {
elements[i].addEventListener('input', saveFilterState, false);
} else {
elements[i].addEventListener('click', saveFilterState, false);
}
}
/*Set up handlers for filters.*/
+10 -17
View File
@@ -256,15 +256,15 @@ namespace loot {
map<string, uint32_t> conflictingPlugins;
YAML::Node node;
if (pluginIt != g_app_state.CurrentGame().plugins.end()) {
for (const auto& pluginPair : g_app_state.CurrentGame().plugins) {
for (const auto& pluginPair : g_app_state.CurrentGame().plugins) {
if (pluginIt != g_app_state.CurrentGame().plugins.end()) {
if (pluginIt->second.DoFormIDsOverlap(pluginPair.second)) {
BOOST_LOG_TRIVIAL(debug) << "Found conflicting plugin: " << pluginPair.second.Name();
conflictingPlugins.emplace(pluginPair.second.Name(), pluginPair.second.Crc());
node["conflicts"].push_back(pluginPair.second.Name());
}
node["crcs"][pluginPair.second.Name()] = pluginPair.second.Crc();
}
node["crcs"][pluginPair.second.Name()] = pluginPair.second.Crc();
}
callback->Success(JSON::stringify(node));
@@ -441,20 +441,13 @@ namespace loot {
BOOST_LOG_TRIVIAL(trace) << "Saving state of filter " << id << " as " << req["args"][2].as<string>();
YAML::Node settings = g_app_state.GetSettings();
if (req["args"][1].as<string>() == "boolean") {
const bool value = req["args"][2].as<bool>();
if (value)
settings["filters"][id] = true;
else
settings["filters"].remove(settings["filters"][id]);
}
else {
const string value = req["args"][2].as<string>();
if (value.empty())
settings["filters"].remove(settings["filters"][id]);
else
settings["filters"][id] = value;
}
const string value = req["args"][2].as<string>();
if (value == "true")
settings["filters"][id] = true;
else if (value == "false" || value.empty())
settings["filters"].remove(id);
else
settings["filters"][id] = value;
g_app_state.UpdateSettings(settings);