Merge lp:~widelands-dev/widelands/compiler-warnings-201908-2 into lp:widelands

Proposed by GunChleoc
Status: Merged
Merged at revision: 9199
Proposed branch: lp:~widelands-dev/widelands/compiler-warnings-201908-2
Merge into: lp:widelands
Diff against target: 519 lines (+79/-71)
24 files modified
src/CMakeLists.txt (+16/-3)
src/ai/defaultai.cc (+0/-1)
src/ai/test/test_ai.cc (+1/-0)
src/economy/test/test_road.cc (+1/-0)
src/economy/test/test_routing.cc (+1/-0)
src/editor/CMakeLists.txt (+1/-1)
src/graphic/styles/font_style.h (+0/-1)
src/graphic/styles/text_panel_style.h (+0/-1)
src/io/filesystem/test/test_filesystem.cc (+1/-0)
src/logic/CMakeLists.txt (+2/-2)
src/logic/map_objects/tribes/productionsite.cc (+1/-1)
src/network/CMakeLists.txt (+1/-0)
src/notifications/test/notifications_test.cc (+1/-0)
src/scripting/CMakeLists.txt (+1/-1)
src/scripting/test/test_luna.cc (+1/-0)
src/sound/CMakeLists.txt (+1/-1)
src/ui_basic/CMakeLists.txt (+1/-0)
src/ui_fsmenu/CMakeLists.txt (+4/-3)
src/ui_fsmenu/options.cc (+1/-1)
src/wlapplication.cc (+12/-4)
src/wlapplication.h (+0/-7)
src/wlapplication_options.cc (+20/-21)
src/wlapplication_options.h (+9/-21)
src/wui/CMakeLists.txt (+3/-2)
To merge this branch: bzr merge lp:~widelands-dev/widelands/compiler-warnings-201908-2
Reviewer Review Type Date Requested Status
Klaus Halfmann Approve
GunChleoc Needs Resubmitting
Review via email: mp+372111@code.launchpad.net

Commit message

Fix compiler warnings and refactor config dir.

Description of the change

Do not send the merge command yet, I want to check the Travis/AppVeyor logs first.

To post a comment you must log in.
Revision history for this message
GunChleoc (gunchleoc) wrote :

I'm done checking the logs, so this is ready for review now.

review: Needs Resubmitting
Revision history for this message
bunnybot (widelandsofficial) wrote :

Continuous integration builds have changed state:

Travis build 5378. State: failed. Details: https://travis-ci.org/widelands/widelands/builds/579360487.
Appveyor build 5148. State: success. Details: https://ci.appveyor.com/project/widelands-dev/widelands/build/_widelands_dev_widelands_compiler_warnings_201908_2-5148.

Revision history for this message
bunnybot (widelandsofficial) wrote :

Continuous integration builds have changed state:

Travis build 5378. State: passed. Details: https://travis-ci.org/widelands/widelands/builds/579360487.
Appveyor build 5148. State: success. Details: https://ci.appveyor.com/project/widelands-dev/widelands/build/_widelands_dev_widelands_compiler_warnings_201908_2-5148.

Revision history for this message
bunnybot (widelandsofficial) wrote :

Continuous integration builds have changed state:

Travis build 5399. State: failed. Details: https://travis-ci.org/widelands/widelands/builds/581705807.
Appveyor build 5169. State: success. Details: https://ci.appveyor.com/project/widelands-dev/widelands/build/_widelands_dev_widelands_compiler_warnings_201908_2-5169.

Revision history for this message
Klaus Halfmann (klaus-halfmann) wrote :

* Replaced:
- widelands_ball_of_mud
+ widelands_options
-> fine

* Codestyle: using this for a member function makes no sense.

* Smuggeled in some USE_XDG handling :-)

Will compile and start this, not doing much testing.

Please: review my refactor_gamehost before merging it becomes to much pain.

review: Approve
Revision history for this message
GunChleoc (gunchleoc) wrote :

Thanks for the review!

I already did a code review on your branch, I guess you overlooked it.

@bunnybot merge

Revision history for this message
bunnybot (widelandsofficial) wrote :

Refusing to merge, since Travis is not green. Use @bunnybot merge force for merging anyways.

Travis build 5399. State: failed. Details: https://travis-ci.org/widelands/widelands/builds/581705807.

Revision history for this message
Klaus Halfmann (klaus-halfmann) wrote :

Locally commpiles without issues. Start upto Lobby was fine.

review: Approve
Revision history for this message
Klaus Halfmann (klaus-halfmann) wrote :

Mhh,one test in travis fails

test/maps/plain.wmf/scripting/test_ui.lua ...
  Running Widelands ... FAIL

But only for GCC_VERSION="4.9" BUILD_TYPE="Debug" ?

will run the test loocally, too

Revision history for this message
GunChleoc (gunchleoc) wrote :

The UI test sometimes fails because it takes too long for the game to close. I have implemented a fix in one of my other branches. Will rerun the Travis job.

Revision history for this message
Klaus Halfmann (klaus-halfmann) wrote :

local tests ok

review: Approve
Revision history for this message
bunnybot (widelandsofficial) wrote :

Continuous integration builds have changed state:

Travis build 5399. State: passed. Details: https://travis-ci.org/widelands/widelands/builds/581705807.
Appveyor build 5169. State: success. Details: https://ci.appveyor.com/project/widelands-dev/widelands/build/_widelands_dev_widelands_compiler_warnings_201908_2-5169.

Revision history for this message
GunChleoc (gunchleoc) wrote :

Thanks again!

@bunnybot merge

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'src/CMakeLists.txt'
--- src/CMakeLists.txt 2019-07-20 14:32:57 +0000
+++ src/CMakeLists.txt 2019-09-06 14:10:07 +0000
@@ -92,8 +92,6 @@
92 wlapplication.h92 wlapplication.h
93 wlapplication_messages.cc93 wlapplication_messages.cc
94 wlapplication_messages.h94 wlapplication_messages.h
95 wlapplication_options.cc
96 wlapplication_options.h
97 USES_SDL295 USES_SDL2
98 USES_SDL2_IMAGE96 USES_SDL2_IMAGE
99 USES_SDL2_TTF97 USES_SDL2_TTF
@@ -109,7 +107,6 @@
109 graphic_fonthandler107 graphic_fonthandler
110 graphic_text108 graphic_text
111 io_filesystem109 io_filesystem
112 io_profile
113 logic110 logic
114 logic_exceptions111 logic_exceptions
115 logic_filesystem_constants112 logic_filesystem_constants
@@ -129,9 +126,25 @@
129 ui_fsmenu_misc126 ui_fsmenu_misc
130 ui_fsmenu_network127 ui_fsmenu_network
131 ui_fsmenu_options128 ui_fsmenu_options
129 widelands_options
132 wui130 wui
133)131)
134132
133wl_library(widelands_options
134 SRCS
135 wlapplication_options.cc
136 wlapplication_options.h
137 USES_SDL2
138 USES_SDL2_IMAGE
139 USES_SDL2_TTF
140 DEPENDS
141 base_log
142 io_filesystem
143 io_profile
144 logic_filesystem_constants
145)
146
147
135# TODO(sirver): Split into libs with useful names.148# TODO(sirver): Split into libs with useful names.
136wl_library(helper149wl_library(helper
137 SRCS150 SRCS
138151
=== modified file 'src/ai/defaultai.cc'
--- src/ai/defaultai.cc 2019-09-05 19:57:55 +0000
+++ src/ai/defaultai.cc 2019-09-06 14:10:07 +0000
@@ -5601,7 +5601,6 @@
5601 inputs[16] = 0;5601 inputs[16] = 0;
5602 inputs[17] = (inputs_on_stock) ? 0 : -2;5602 inputs[17] = (inputs_on_stock) ? 0 : -2;
5603 inputs[18] = (suppliers_exist) ? 0 : -3;5603 inputs[18] = (suppliers_exist) ? 0 : -3;
5604 ;
5605 inputs[19] = (inputs_on_stock) ? 0 : -4;5604 inputs[19] = (inputs_on_stock) ? 0 : -4;
5606 inputs[20] =5605 inputs[20] =
5607 (mines_per_type[bo.mines].in_construction + mines_per_type[bo.mines].finished == 1) ?5606 (mines_per_type[bo.mines].in_construction + mines_per_type[bo.mines].finished == 1) ?
56085607
=== modified file 'src/ai/test/test_ai.cc'
--- src/ai/test/test_ai.cc 2019-08-31 20:12:56 +0000
+++ src/ai/test/test_ai.cc 2019-09-06 14:10:07 +0000
@@ -29,6 +29,7 @@
2929
30// Triggered by BOOST_AUTO_TEST_CASE30// Triggered by BOOST_AUTO_TEST_CASE
31CLANG_DIAG_OFF("-Wdisabled-macro-expansion")31CLANG_DIAG_OFF("-Wdisabled-macro-expansion")
32CLANG_DIAG_OFF("-Wused-but-marked-unused")
3233
33using namespace Widelands;34using namespace Widelands;
3435
3536
=== modified file 'src/economy/test/test_road.cc'
--- src/economy/test/test_road.cc 2019-02-23 11:00:49 +0000
+++ src/economy/test/test_road.cc 2019-09-06 14:10:07 +0000
@@ -33,6 +33,7 @@
3333
34// Triggered by BOOST_AUTO_TEST_CASE34// Triggered by BOOST_AUTO_TEST_CASE
35CLANG_DIAG_OFF("-Wdisabled-macro-expansion")35CLANG_DIAG_OFF("-Wdisabled-macro-expansion")
36CLANG_DIAG_OFF("-Wused-but-marked-unused")
3637
37namespace Widelands {38namespace Widelands {
38class World;39class World;
3940
=== modified file 'src/economy/test/test_routing.cc'
--- src/economy/test/test_routing.cc 2019-02-23 11:00:49 +0000
+++ src/economy/test/test_routing.cc 2019-09-06 14:10:07 +0000
@@ -33,6 +33,7 @@
3333
34// Triggered by BOOST_AUTO_TEST_CASE34// Triggered by BOOST_AUTO_TEST_CASE
35CLANG_DIAG_OFF("-Wdisabled-macro-expansion")35CLANG_DIAG_OFF("-Wdisabled-macro-expansion")
36CLANG_DIAG_OFF("-Wused-but-marked-unused")
3637
37using namespace Widelands;38using namespace Widelands;
3839
3940
=== modified file 'src/editor/CMakeLists.txt'
--- src/editor/CMakeLists.txt 2019-08-27 19:00:30 +0000
+++ src/editor/CMakeLists.txt 2019-09-06 14:10:07 +0000
@@ -115,7 +115,7 @@
115 scripting_lua_interface115 scripting_lua_interface
116 scripting_lua_table116 scripting_lua_table
117 ui_basic117 ui_basic
118 widelands_ball_of_mud118 widelands_options
119 wui119 wui
120 wui_common_mapdetails120 wui_common_mapdetails
121 wui_mapview_pixelfunctions121 wui_mapview_pixelfunctions
122122
=== 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-09-06 14:10:07 +0000
@@ -67,7 +67,6 @@
67 bool init_underline,67 bool init_underline,
68 bool init_shadow);68 bool init_shadow);
69 explicit FontStyleInfo(const FontStyleInfo& other);69 explicit FontStyleInfo(const FontStyleInfo& other);
70 FontStyleInfo& operator=(const FontStyleInfo& other) = default;
7170
72 std::string as_font_tag(const std::string& text) const;71 std::string as_font_tag(const std::string& text) const;
7372
7473
=== 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-09-06 14:10:07 +0000
@@ -38,7 +38,6 @@
38 : background_(new UI::PanelStyleInfo(other.background())),38 : background_(new UI::PanelStyleInfo(other.background())),
39 font_(new UI::FontStyleInfo(other.font())) {39 font_(new UI::FontStyleInfo(other.font())) {
40 }40 }
41 TextPanelStyleInfo& operator=(const TextPanelStyleInfo& other) = default;
4241
43 const UI::FontStyleInfo& font() const {42 const UI::FontStyleInfo& font() const {
44 return *font_.get();43 return *font_.get();
4544
=== modified file 'src/io/filesystem/test/test_filesystem.cc'
--- src/io/filesystem/test/test_filesystem.cc 2019-04-09 16:43:49 +0000
+++ src/io/filesystem/test/test_filesystem.cc 2019-09-06 14:10:07 +0000
@@ -49,6 +49,7 @@
4949
50// Triggered by BOOST_AUTO_TEST_CASE50// Triggered by BOOST_AUTO_TEST_CASE
51CLANG_DIAG_OFF("-Wdisabled-macro-expansion")51CLANG_DIAG_OFF("-Wdisabled-macro-expansion")
52CLANG_DIAG_OFF("-Wused-but-marked-unused")
5253
53BOOST_AUTO_TEST_SUITE(FileSystemTests)54BOOST_AUTO_TEST_SUITE(FileSystemTests)
54#ifndef _WIN3255#ifndef _WIN32
5556
=== modified file 'src/logic/CMakeLists.txt'
--- src/logic/CMakeLists.txt 2019-08-27 19:00:30 +0000
+++ src/logic/CMakeLists.txt 2019-09-06 14:10:07 +0000
@@ -63,7 +63,7 @@
63 logic_commands63 logic_commands
64 logic_game_settings64 logic_game_settings
65 ui_basic65 ui_basic
66 widelands_ball_of_mud66 widelands_options
67 wui67 wui
68)68)
6969
@@ -258,7 +258,7 @@
258 sound258 sound
259 sound_constants259 sound_constants
260 ui_basic260 ui_basic
261 widelands_ball_of_mud261 widelands_options
262 wui # TODO(GunChleoc): Circular dependency262 wui # TODO(GunChleoc): Circular dependency
263)263)
264264
265265
=== modified file 'src/logic/map_objects/tribes/productionsite.cc'
--- src/logic/map_objects/tribes/productionsite.cc 2019-08-20 17:35:33 +0000
+++ src/logic/map_objects/tribes/productionsite.cc 2019-09-06 14:10:07 +0000
@@ -1090,7 +1090,7 @@
1090 static const uint32_t entire_duration = 10 * 60 * 1000;1090 static const uint32_t entire_duration = 10 * 60 * 1000;
1091 if (duration > duration_cap) {1091 if (duration > duration_cap) {
1092 duration = duration_cap;1092 duration = duration_cap;
1093 };1093 }
1094 const uint32_t past_duration = entire_duration - duration;1094 const uint32_t past_duration = entire_duration - duration;
1095 crude_percent_ =1095 crude_percent_ =
1096 (crude_percent_ * past_duration + produced * duration * 10000) / entire_duration;1096 (crude_percent_ * past_duration + produced * duration * 10000) / entire_duration;
10971097
=== modified file 'src/network/CMakeLists.txt'
--- src/network/CMakeLists.txt 2019-08-27 19:00:30 +0000
+++ src/network/CMakeLists.txt 2019-09-06 14:10:07 +0000
@@ -61,5 +61,6 @@
61 ui_basic61 ui_basic
62 ui_fsmenu_gameloading62 ui_fsmenu_gameloading
63 widelands_ball_of_mud63 widelands_ball_of_mud
64 widelands_options
64 wui65 wui
65)66)
6667
=== modified file 'src/notifications/test/notifications_test.cc'
--- src/notifications/test/notifications_test.cc 2019-02-23 11:00:49 +0000
+++ src/notifications/test/notifications_test.cc 2019-09-06 14:10:07 +0000
@@ -29,6 +29,7 @@
2929
30// Triggered by BOOST_AUTO_TEST_CASE30// Triggered by BOOST_AUTO_TEST_CASE
31CLANG_DIAG_OFF("-Wdisabled-macro-expansion")31CLANG_DIAG_OFF("-Wdisabled-macro-expansion")
32CLANG_DIAG_OFF("-Wused-but-marked-unused")
3233
33struct SimpleNote {34struct SimpleNote {
34 CAN_BE_SENT_AS_NOTE(100)35 CAN_BE_SENT_AS_NOTE(100)
3536
=== modified file 'src/scripting/CMakeLists.txt'
--- src/scripting/CMakeLists.txt 2019-08-27 19:00:30 +0000
+++ src/scripting/CMakeLists.txt 2019-09-06 14:10:07 +0000
@@ -129,7 +129,7 @@
129 scripting_luna129 scripting_luna
130 third_party_eris130 third_party_eris
131 ui_basic131 ui_basic
132 widelands_ball_of_mud132 widelands_options
133 wui133 wui
134 wui_mapview_pixelfunctions134 wui_mapview_pixelfunctions
135)135)
136136
=== modified file 'src/scripting/test/test_luna.cc'
--- src/scripting/test/test_luna.cc 2019-02-23 11:00:49 +0000
+++ src/scripting/test/test_luna.cc 2019-09-06 14:10:07 +0000
@@ -30,6 +30,7 @@
3030
31// Triggered by BOOST_AUTO_TEST_CASE31// Triggered by BOOST_AUTO_TEST_CASE
32CLANG_DIAG_OFF("-Wdisabled-macro-expansion")32CLANG_DIAG_OFF("-Wdisabled-macro-expansion")
33CLANG_DIAG_OFF("-Wused-but-marked-unused")
3334
34#ifndef BEGIN_LUNA_PROPERTIES35#ifndef BEGIN_LUNA_PROPERTIES
35#define BEGIN_LUNA_PROPERTIES(klass) const PropertyType<klass> klass::Properties[] = {36#define BEGIN_LUNA_PROPERTIES(klass) const PropertyType<klass> klass::Properties[] = {
3637
=== modified file 'src/sound/CMakeLists.txt'
--- src/sound/CMakeLists.txt 2019-08-27 19:00:30 +0000
+++ src/sound/CMakeLists.txt 2019-09-06 14:10:07 +0000
@@ -34,5 +34,5 @@
34 logic_exceptions34 logic_exceptions
35 random35 random
36 sound_constants36 sound_constants
37 widelands_ball_of_mud37 widelands_options
38)38)
3939
=== modified file 'src/ui_basic/CMakeLists.txt'
--- src/ui_basic/CMakeLists.txt 2019-08-27 19:00:30 +0000
+++ src/ui_basic/CMakeLists.txt 2019-09-06 14:10:07 +0000
@@ -76,4 +76,5 @@
76 sound76 sound
77 sound_constants77 sound_constants
78 widelands_ball_of_mud78 widelands_ball_of_mud
79 widelands_options
79)80)
8081
=== modified file 'src/ui_fsmenu/CMakeLists.txt'
--- src/ui_fsmenu/CMakeLists.txt 2019-08-27 19:00:30 +0000
+++ src/ui_fsmenu/CMakeLists.txt 2019-09-06 14:10:07 +0000
@@ -19,6 +19,7 @@
19 ui_fsmenu_base19 ui_fsmenu_base
20 sound20 sound
21 widelands_ball_of_mud21 widelands_ball_of_mud
22 widelands_options
22 wui_sound_options23 wui_sound_options
23)24)
2425
@@ -81,7 +82,7 @@
81 ui_basic82 ui_basic
82 ui_fsmenu_base83 ui_fsmenu_base
83 ui_fsmenu_main_menu84 ui_fsmenu_main_menu
84 widelands_ball_of_mud85 widelands_options
85 wui_common_mapdetails86 wui_common_mapdetails
86 wui87 wui
87)88)
@@ -118,7 +119,7 @@
118 ui_fsmenu_helpwindow119 ui_fsmenu_helpwindow
119 ui_fsmenu_loading_common120 ui_fsmenu_loading_common
120 ui_fsmenu_maploading121 ui_fsmenu_maploading
121 widelands_ball_of_mud122 widelands_options
122 wui123 wui
123 wui_chat_ui124 wui_chat_ui
124 wui_common_gamedetails125 wui_common_gamedetails
@@ -177,7 +178,7 @@
177 sound178 sound
178 ui_basic179 ui_basic
179 ui_fsmenu_base180 ui_fsmenu_base
180 widelands_ball_of_mud181 widelands_options
181 wui_chat_ui182 wui_chat_ui
182)183)
183184
184185
=== 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-09-06 14:10:07 +0000
@@ -680,5 +680,5 @@
680 g_sh->save_config();680 g_sh->save_config();
681681
682 // Now write to file682 // Now write to file
683 write_config(WLApplication::get());683 write_config();
684}684}
685685
=== modified file 'src/wlapplication.cc'
--- src/wlapplication.cc 2019-09-05 20:04:47 +0000
+++ src/wlapplication.cc 2019-09-06 14:10:07 +0000
@@ -228,6 +228,9 @@
228228
229// Set up the homedir. Exit 1 if the homedir is illegal or the logger couldn't be initialized for229// Set up the homedir. Exit 1 if the homedir is illegal or the logger couldn't be initialized for
230// Windows.230// Windows.
231// Also sets the config directory. This defaults to $XDG_CONFIG_HOME/widelands/config on Unix.
232// Defaults to homedir/config everywhere else, if homedir is set manually or if
233// built without XDG-support.
231void WLApplication::setup_homedir() {234void WLApplication::setup_homedir() {
232 // Check if we have a command line override235 // Check if we have a command line override
233 if (commandline_.count("homedir")) {236 if (commandline_.count("homedir")) {
@@ -274,6 +277,12 @@
274 // Homedir is ready, so we can log normally from now on277 // Homedir is ready, so we can log normally from now on
275 log("Set home directory: %s\n", homedir_.c_str());278 log("Set home directory: %s\n", homedir_.c_str());
276 }279 }
280
281#ifdef USE_XDG
282 set_config_directory(userconfigdir_);
283#else
284 set_config_directory(homedir_);
285#endif
277}286}
278287
279WLApplication* WLApplication::the_singleton = nullptr;288WLApplication* WLApplication::the_singleton = nullptr;
@@ -766,7 +775,7 @@
766bool WLApplication::init_settings() {775bool WLApplication::init_settings() {
767776
768 // Read in the configuration file777 // Read in the configuration file
769 read_config(this);778 read_config();
770779
771 // Then parse the commandline - overwrites conffile settings780 // Then parse the commandline - overwrites conffile settings
772 handle_commandline_parameters();781 handle_commandline_parameters();
@@ -846,7 +855,7 @@
846855
847 // Save configuration now. Otherwise, the UUID is not saved856 // Save configuration now. Otherwise, the UUID is not saved
848 // when the game crashes, losing part of its advantage857 // when the game crashes, losing part of its advantage
849 write_config(this);858 write_config();
850859
851 return true;860 return true;
852}861}
@@ -872,8 +881,7 @@
872void WLApplication::shutdown_settings() {881void WLApplication::shutdown_settings() {
873 // To be proper, release our textdomain882 // To be proper, release our textdomain
874 i18n::release_textdomain();883 i18n::release_textdomain();
875884 write_config();
876 write_config(this);
877}885}
878886
879void WLApplication::shutdown_hardware() {887void WLApplication::shutdown_hardware() {
880888
=== modified file 'src/wlapplication.h'
--- src/wlapplication.h 2019-07-20 14:32:57 +0000
+++ src/wlapplication.h 2019-09-06 14:10:07 +0000
@@ -196,13 +196,6 @@
196 void replay();196 void replay();
197 static void emergency_save(Widelands::Game&);197 static void emergency_save(Widelands::Game&);
198198
199#ifdef USE_XDG
200 // this is only for src/wlapplication_options.cc
201 std::string get_userconfigdir() {
202 return userconfigdir_;
203 }
204#endif
205
206private:199private:
207 WLApplication(int argc, char const* const* argv);200 WLApplication(int argc, char const* const* argv);
208201
209202
=== modified file 'src/wlapplication_options.cc'
--- src/wlapplication_options.cc 2019-08-31 03:22:10 +0000
+++ src/wlapplication_options.cc 2019-09-06 14:10:07 +0000
@@ -19,14 +19,17 @@
1919
20#include "wlapplication_options.h"20#include "wlapplication_options.h"
2121
22#include <cassert>
23#include <memory>
24
22#include "base/log.h"25#include "base/log.h"
23#include "io/filesystem/disk_filesystem.h"26#include "io/filesystem/disk_filesystem.h"
24#include "io/profile.h"
25#include "logic/filesystem_constants.h"27#include "logic/filesystem_constants.h"
26#include "wlapplication.h"
2728
28static Profile g_options(Profile::err_log);29static Profile g_options(Profile::err_log);
2930
31static std::unique_ptr<FileSystem> config_dir = nullptr;
32
30void check_config_used() {33void check_config_used() {
31 g_options.check_used();34 g_options.check_used();
32}35}
@@ -110,26 +113,22 @@
110 g_options.pull_section(section.c_str()).set_string(name.c_str(), value.c_str());113 g_options.pull_section(section.c_str()).set_string(name.c_str(), value.c_str());
111}114}
112115
113void read_config(WLApplication* wlapplication) {116
114#ifdef USE_XDG117void set_config_directory(const std::string& userconfigdir) {
115 RealFSImpl dir(wlapplication->get_userconfigdir());118 config_dir.reset(new RealFSImpl(userconfigdir));
116 dir.ensure_directory_exists(".");119 config_dir->ensure_directory_exists(".");
117 log("Set configuration file: %s/%s\n", wlapplication->get_userconfigdir().c_str(),120 log("Set configuration file: %s/%s\n", userconfigdir.c_str(), kConfigFile.c_str());
118 kConfigFile.c_str());121}
119 g_options.read(kConfigFile.c_str(), "global", dir);122
120#else123void read_config() {
121 g_options.read(kConfigFile.c_str(), "global");124 assert(config_dir != nullptr);
122#endif125 g_options.read(kConfigFile.c_str(), "global", *config_dir);
123}126}
124127
125void write_config(WLApplication* wlapplication) {128void write_config() {
129 assert(config_dir != nullptr);
126 try { // overwrite the old config file130 try { // overwrite the old config file
127#ifdef USE_XDG131 g_options.write(kConfigFile.c_str(), true, *config_dir);
128 RealFSImpl dir(wlapplication->get_userconfigdir());
129 g_options.write(kConfigFile.c_str(), true, dir);
130#else
131 g_options.write(kConfigFile.c_str(), true);
132#endif
133 } catch (const std::exception& e) {132 } catch (const std::exception& e) {
134 log("WARNING: could not save configuration: %s\n", e.what());133 log("WARNING: could not save configuration: %s\n", e.what());
135 } catch (...) {134 } catch (...) {
136135
=== modified file 'src/wlapplication_options.h'
--- src/wlapplication_options.h 2019-08-28 18:34:58 +0000
+++ src/wlapplication_options.h 2019-09-06 14:10:07 +0000
@@ -21,7 +21,6 @@
21#define WL_WLAPPLICATION_OPTIONS_H21#define WL_WLAPPLICATION_OPTIONS_H
2222
23#include "io/profile.h"23#include "io/profile.h"
24#include "wlapplication.h"
2524
26/*25/*
27 * Further explanations for all functions and its return values26 * Further explanations for all functions and its return values
@@ -77,31 +76,20 @@
77 const std::string& value);76 const std::string& value);
7877
79/*78/*
79 * Sets the directory where to read/write kConfigFile.
80 */
81void set_config_directory(const std::string& userconfigdir);
82
83/*
80 * Reads the configuration from kConfigFile.84 * Reads the configuration from kConfigFile.
81 * Defaults to $XDG_CONFIG_HOME/widelands/config on Unix.85 * Assumes that set_config_directory has been called.
82 * Defaults to homedir/config everywhere else, if homedir is set manually or if
83 * built without XDG-support.
84 *
85 * This function needs access to the WLApplication object to distinguish
86 * between multiple possible states.
87 * While we could use WLApplication::get() this would get us in an infinite loop
88 * because this function will be called in the constructor of said object and
89 * WLApplication::get() spawns another object if there isn't one yet.
90 */86 */
91void read_config(WLApplication*);87void read_config();
9288
93/*89/*
94 * Writes the configuration to kConfigFile.90 * Writes the configuration to kConfigFile.
95 * Defaults to $XDG_CONFIG_HOME/widelands/config on Unix.91 * * Assumes that set_config_directory has been called.
96 * Defaults to homedir/config everywhere else, if homedir is set manually or if
97 * built without XDG-support.
98 *
99 * This function needs access to the WLApplication object to distinguish
100 * between multiple possible states.
101 * While we could use WLApplication::get() this would get us in an infinite loop
102 * because this function will be called in the constructor of said object and
103 * WLApplication::get() spawns another object if there isn't one yet.
104 */92 */
105void write_config(WLApplication*);93void write_config();
10694
107#endif // end of include guard: WL_WLAPPLICATION_OPTIONS_H95#endif // end of include guard: WL_WLAPPLICATION_OPTIONS_H
10896
=== modified file 'src/wui/CMakeLists.txt'
--- src/wui/CMakeLists.txt 2019-08-27 19:00:30 +0000
+++ src/wui/CMakeLists.txt 2019-09-06 14:10:07 +0000
@@ -33,7 +33,7 @@
33 logic33 logic
34 sound34 sound
35 ui_basic35 ui_basic
36 widelands_ball_of_mud36 widelands_options
37 wui37 wui
38)38)
3939
@@ -154,6 +154,7 @@
154 logic_widelands_geometry154 logic_widelands_geometry
155 ui_basic155 ui_basic
156 widelands_ball_of_mud156 widelands_ball_of_mud
157 widelands_options
157 wui_mapview_pixelfunctions158 wui_mapview_pixelfunctions
158)159)
159160
@@ -314,7 +315,7 @@
314 scripting_lua_table315 scripting_lua_table
315 sound316 sound
316 ui_basic317 ui_basic
317 widelands_ball_of_mud318 widelands_options
318 wui_chat_ui319 wui_chat_ui
319 wui_common_gamedetails320 wui_common_gamedetails
320 wui_economy_options321 wui_economy_options

Subscribers

People subscribed via source and target branches

to status/vote changes: