Additional minor fixes to Linux build

This commit is contained in:
2017-01-26 17:18:01 -05:00
parent dde0212dc4
commit 37d2e5f06b
3 changed files with 4 additions and 3 deletions

View File

@@ -117,7 +117,7 @@ public:
if(getSupportedHandlers().count(t) == 0) throw xHandlerNotSupported(t);
auto old_handler = event_handlers[t];
if(handler) event_handlers[t] = handler;
else event_handlers[t].clear();
else event_handlers[t] = nullptr;
if(old_handler.empty()) return nullptr;
return boost::any_cast<typename event_fcn<t>::type>(old_handler);
}

View File

@@ -41,7 +41,7 @@ void append_iarray_pref(std::string keypath, int value) {
if(prefs.find(keypath) == prefs.end() || prefs[keypath].type() != typeid(iarray))
prefs[keypath] = iarray{value};
else {
iarray& arr = boost::any_cast<iarray>(prefs[keypath]);
iarray& arr = boost::any_cast<iarray&>(prefs[keypath]);
arr.push_back(value);
prefs[keypath] = arr;
}
@@ -65,7 +65,7 @@ static bool save_prefs(fs::path fpath) {
std::ofstream fout(fpath.string().c_str());
for(auto& kv : prefs) {
if(kv.second.type() == typeid(iarray)) {
iarray& arr = boost::any_cast<iarray>(kv.second);
iarray& arr = boost::any_cast<iarray&>(kv.second);
fout << kv.first << " = [";
for(int i : arr) fout << i << ' ';
fout.seekp(-1,std::ios::cur); // To overwrite the final space written in the loop

View File

@@ -11,6 +11,7 @@
#include <cstdio>
#include <ctime>
#include <cstring>
#include <stdexcept>
#ifdef _MSC_VER
// For some bizarre reason, Visual Studio doesn't declare snprintf in <cstdio>