widelands-dev team mailing list archive
-
widelands-dev team
-
Mailing list archive
-
Message #18090
[Merge] lp:~widelands-dev/widelands/compiler-warnings-201908-2 into lp:widelands
GunChleoc has proposed merging lp:~widelands-dev/widelands/compiler-warnings-201908-2 into lp:widelands.
Commit message:
Fix compiler warnings and refactor config dir.
Requested reviews:
Widelands Developers (widelands-dev)
For more details, see:
https://code.launchpad.net/~widelands-dev/widelands/compiler-warnings-201908-2/+merge/372111
Do not send the merge command yet, I want to check the Travis/AppVeyor logs first.
--
Your team Widelands Developers is requested to review the proposed merge of lp:~widelands-dev/widelands/compiler-warnings-201908-2 into lp:widelands.
=== modified file 'src/graphic/styles/font_style.h'
--- src/graphic/styles/font_style.h 2019-06-01 14:16:25 +0000
+++ src/graphic/styles/font_style.h 2019-08-31 10:33:28 +0000
@@ -67,7 +67,6 @@
bool init_underline,
bool init_shadow);
explicit FontStyleInfo(const FontStyleInfo& other);
- FontStyleInfo& operator=(const FontStyleInfo& other) = default;
std::string as_font_tag(const std::string& text) const;
=== modified file 'src/graphic/styles/text_panel_style.h'
--- src/graphic/styles/text_panel_style.h 2019-05-26 17:21:15 +0000
+++ src/graphic/styles/text_panel_style.h 2019-08-31 10:33:28 +0000
@@ -38,7 +38,6 @@
: background_(new UI::PanelStyleInfo(other.background())),
font_(new UI::FontStyleInfo(other.font())) {
}
- TextPanelStyleInfo& operator=(const TextPanelStyleInfo& other) = default;
const UI::FontStyleInfo& font() const {
return *font_.get();
=== modified file 'src/ui_fsmenu/options.cc'
--- src/ui_fsmenu/options.cc 2019-08-25 14:50:16 +0000
+++ src/ui_fsmenu/options.cc 2019-08-31 10:33:28 +0000
@@ -680,5 +680,5 @@
g_sh->save_config();
// Now write to file
- write_config(WLApplication::get());
+ write_config();
}
=== modified file 'src/wlapplication.cc'
--- src/wlapplication.cc 2019-08-28 06:12:07 +0000
+++ src/wlapplication.cc 2019-08-31 10:33:28 +0000
@@ -228,6 +228,9 @@
// Set up the homedir. Exit 1 if the homedir is illegal or the logger couldn't be initialized for
// Windows.
+// Also sets the config directory. This defaults to $XDG_CONFIG_HOME/widelands/config on Unix.
+// Defaults to homedir/config everywhere else, if homedir is set manually or if
+// built without XDG-support.
void WLApplication::setup_homedir() {
// Check if we have a command line override
if (commandline_.count("homedir")) {
@@ -274,6 +277,12 @@
// Homedir is ready, so we can log normally from now on
log("Set home directory: %s\n", homedir_.c_str());
}
+
+#ifdef USE_XDG
+ set_config_directory(userconfigdir_);
+#else
+ set_config_directory(homedir_);
+#endif
}
WLApplication* WLApplication::the_singleton = nullptr;
@@ -766,7 +775,7 @@
bool WLApplication::init_settings() {
// Read in the configuration file
- read_config(this);
+ read_config();
// Then parse the commandline - overwrites conffile settings
handle_commandline_parameters();
@@ -846,7 +855,7 @@
// Save configuration now. Otherwise, the UUID is not saved
// when the game crashes, losing part of its advantage
- write_config(this);
+ write_config();
return true;
}
@@ -872,8 +881,7 @@
void WLApplication::shutdown_settings() {
// To be proper, release our textdomain
i18n::release_textdomain();
-
- write_config(this);
+ write_config();
}
void WLApplication::shutdown_hardware() {
=== modified file 'src/wlapplication.h'
--- src/wlapplication.h 2019-07-20 14:32:57 +0000
+++ src/wlapplication.h 2019-08-31 10:33:28 +0000
@@ -196,13 +196,6 @@
void replay();
static void emergency_save(Widelands::Game&);
-#ifdef USE_XDG
- // this is only for src/wlapplication_options.cc
- std::string get_userconfigdir() {
- return userconfigdir_;
- }
-#endif
-
private:
WLApplication(int argc, char const* const* argv);
=== modified file 'src/wlapplication_options.cc'
--- src/wlapplication_options.cc 2019-08-28 06:12:07 +0000
+++ src/wlapplication_options.cc 2019-08-31 10:33:28 +0000
@@ -19,13 +19,17 @@
#include "wlapplication_options.h"
+#include <cassert>
+#include <memory>
+
#include "base/log.h"
#include "io/filesystem/disk_filesystem.h"
#include "io/profile.h"
#include "logic/filesystem_constants.h"
-#include "wlapplication.h"
-
-Profile g_options(Profile::err_log);
+
+static Profile g_options(Profile::err_log);
+
+static std::unique_ptr<FileSystem> config_dir = nullptr;
void check_config_used() {
g_options.check_used();
@@ -110,26 +114,22 @@
g_options.pull_section(section.c_str()).set_string(name.c_str(), value.c_str());
}
-void read_config(WLApplication* wlapplication) {
-#ifdef USE_XDG
- RealFSImpl dir(wlapplication->get_userconfigdir());
- dir.ensure_directory_exists(".");
- log("Set configuration file: %s/%s\n", wlapplication->get_userconfigdir().c_str(),
- kConfigFile.c_str());
- g_options.read(kConfigFile.c_str(), "global", dir);
-#else
- g_options.read(kConfigFile.c_str(), "global");
-#endif
-}
-
-void write_config(WLApplication* wlapplication) {
+
+void set_config_directory(const std::string& userconfigdir) {
+ config_dir.reset(new RealFSImpl(userconfigdir));
+ config_dir->ensure_directory_exists(".");
+ log("Set configuration file: %s/%s\n", userconfigdir.c_str(), kConfigFile.c_str());
+}
+
+void read_config() {
+ assert(config_dir != nullptr);
+ g_options.read(kConfigFile.c_str(), "global", *config_dir);
+}
+
+void write_config() {
+ assert(config_dir != nullptr);
try { // overwrite the old config file
-#ifdef USE_XDG
- RealFSImpl dir(wlapplication->get_userconfigdir());
- g_options.write(kConfigFile.c_str(), true, dir);
-#else
- g_options.write(kConfigFile.c_str(), true);
-#endif
+ g_options.write(kConfigFile.c_str(), true, *config_dir);
} catch (const std::exception& e) {
log("WARNING: could not save configuration: %s\n", e.what());
} catch (...) {
=== modified file 'src/wlapplication_options.h'
--- src/wlapplication_options.h 2019-08-28 18:34:58 +0000
+++ src/wlapplication_options.h 2019-08-31 10:33:28 +0000
@@ -21,7 +21,6 @@
#define WL_WLAPPLICATION_OPTIONS_H
#include "io/profile.h"
-#include "wlapplication.h"
/*
* Further explanations for all functions and its return values
@@ -77,31 +76,20 @@
const std::string& value);
/*
+ * Sets the directory where to read/write kConfigFile.
+ */
+void set_config_directory(const std::string& userconfigdir);
+
+/*
* Reads the configuration from kConfigFile.
- * Defaults to $XDG_CONFIG_HOME/widelands/config on Unix.
- * Defaults to homedir/config everywhere else, if homedir is set manually or if
- * built without XDG-support.
- *
- * This function needs access to the WLApplication object to distinguish
- * between multiple possible states.
- * While we could use WLApplication::get() this would get us in an infinite loop
- * because this function will be called in the constructor of said object and
- * WLApplication::get() spawns another object if there isn't one yet.
+ * Assumes that set_config_directory has been called.
*/
-void read_config(WLApplication*);
+void read_config();
/*
* Writes the configuration to kConfigFile.
- * Defaults to $XDG_CONFIG_HOME/widelands/config on Unix.
- * Defaults to homedir/config everywhere else, if homedir is set manually or if
- * built without XDG-support.
- *
- * This function needs access to the WLApplication object to distinguish
- * between multiple possible states.
- * While we could use WLApplication::get() this would get us in an infinite loop
- * because this function will be called in the constructor of said object and
- * WLApplication::get() spawns another object if there isn't one yet.
+ * * Assumes that set_config_directory has been called.
*/
-void write_config(WLApplication*);
+void write_config();
#endif // end of include guard: WL_WLAPPLICATION_OPTIONS_H
=== modified file 'src/wui/constructionsitewindow.cc'
--- src/wui/constructionsitewindow.cc 2019-07-11 08:38:29 +0000
+++ src/wui/constructionsitewindow.cc 2019-08-31 10:33:28 +0000
@@ -30,10 +30,6 @@
static const char pic_tab_settings[] = "images/wui/menus/statistics_stock.png";
static const char pic_tab_settings_wares[] = "images/wui/stats/menu_tab_wares_warehouse.png";
static const char pic_tab_settings_workers[] = "images/wui/stats/menu_tab_workers_warehouse.png";
-static const char pic_max_fill_indicator[] = "images/wui/buildings/max_fill_indicator.png";
-static const char pic_priority_low[] = "images/wui/buildings/low_priority_button.png";
-static const char pic_priority_normal[] = "images/wui/buildings/normal_priority_button.png";
-static const char pic_priority_high[] = "images/wui/buildings/high_priority_button.png";
static const char pic_stock_policy_prefer[] = "images/wui/buildings/stock_policy_prefer.png";
static const char pic_stock_policy_dontstock[] = "images/wui/buildings/stock_policy_dontstock.png";
static const char pic_stock_policy_remove[] = "images/wui/buildings/stock_policy_remove.png";
Follow ups
-
[Merge] lp:~widelands-dev/widelands/compiler-warnings-201908-2 into lp:widelands
From: noreply, 2019-09-07
-
Re: [Merge] lp:~widelands-dev/widelands/compiler-warnings-201908-2 into lp:widelands
From: GunChleoc, 2019-09-07
-
[Merge] lp:~widelands-dev/widelands/compiler-warnings-201908-2 into lp:widelands
From: bunnybot, 2019-09-07
-
Re: [Merge] lp:~widelands-dev/widelands/compiler-warnings-201908-2 into lp:widelands
From: Klaus Halfmann, 2019-09-07
-
Re: [Merge] lp:~widelands-dev/widelands/compiler-warnings-201908-2 into lp:widelands
From: GunChleoc, 2019-09-07
-
Re: [Merge] lp:~widelands-dev/widelands/compiler-warnings-201908-2 into lp:widelands
From: Klaus Halfmann, 2019-09-07
-
Re: [Merge] lp:~widelands-dev/widelands/compiler-warnings-201908-2 into lp:widelands
From: Klaus Halfmann, 2019-09-07
-
[Merge] lp:~widelands-dev/widelands/compiler-warnings-201908-2 into lp:widelands
From: bunnybot, 2019-09-07
-
Re: [Merge] lp:~widelands-dev/widelands/compiler-warnings-201908-2 into lp:widelands
From: GunChleoc, 2019-09-07
-
Re: [Merge] lp:~widelands-dev/widelands/compiler-warnings-201908-2 into lp:widelands
From: Klaus Halfmann, 2019-09-07
-
[Merge] lp:~widelands-dev/widelands/compiler-warnings-201908-2 into lp:widelands
From: bunnybot, 2019-09-06
-
[Merge] lp:~widelands-dev/widelands/compiler-warnings-201908-2 into lp:widelands
From: bunnybot, 2019-09-01
-
[Merge] lp:~widelands-dev/widelands/compiler-warnings-201908-2 into lp:widelands
From: bunnybot, 2019-09-01
-
Re: [Merge] lp:~widelands-dev/widelands/compiler-warnings-201908-2 into lp:widelands
From: GunChleoc, 2019-09-01