Move assert into filesystem::get_user_data_path()
As discussed previously in https://github.com/wesnoth/wesnoth/pull/9016#discussion_r1650036348
This commit is contained in:
parent
2704adf70d
commit
4f40c9deb5
4 changed files with 4 additions and 11 deletions
|
@ -786,10 +786,7 @@ void set_cache_dir(const std::string& newcachedir)
|
|||
|
||||
static const bfs::path& get_user_data_path()
|
||||
{
|
||||
if(user_data_dir.empty()) {
|
||||
set_user_data_dir(std::string());
|
||||
}
|
||||
|
||||
assert(!user_data_dir.empty() && "Attempted to access userdata location before userdata initialization!");
|
||||
return user_data_dir;
|
||||
}
|
||||
|
||||
|
|
|
@ -189,13 +189,6 @@ class prefs
|
|||
public:
|
||||
static prefs& get()
|
||||
{
|
||||
// for wesnoth: checks that the userdata folders have been initialized/found since if it hasn't been then it's too soon to be getting any values from it
|
||||
// for boost: the userdata folders don't get initialized and the preferences aren't used for anything, so skip the check here
|
||||
// macos - called "unit_tests"
|
||||
// others - called "boost_unit_tests"
|
||||
static bool called_before_init = !(filesystem::base_name(filesystem::get_exe_path()).find("unit_tests") == std::string::npos && !filesystem::is_userdata_initialized());
|
||||
assert(called_before_init && "Attempt to use preferences before userdata initialization");
|
||||
|
||||
static prefs prefs_manager;
|
||||
return prefs_manager;
|
||||
}
|
||||
|
|
|
@ -411,6 +411,8 @@ config server::read_config() const
|
|||
}
|
||||
|
||||
try {
|
||||
// necessary to avoid assert since preprocess_file() goes through filesystem::get_short_wml_path()
|
||||
filesystem::set_user_data_dir(std::string());
|
||||
filesystem::scoped_istream stream = preprocess_file(config_file_);
|
||||
read(configuration, *stream);
|
||||
LOG_SERVER << "Server configuration from file: '" << config_file_ << "' read.";
|
||||
|
|
|
@ -77,6 +77,7 @@ struct wesnoth_global_fixture {
|
|||
results_reporter::set_stream(reporter);
|
||||
// lg::set_log_domain_severity("all",lg::debug());
|
||||
game_config::path = filesystem::get_cwd();
|
||||
filesystem::set_user_data_dir(std::string());
|
||||
|
||||
// declare this here so that it will always be at the front of the event queue.
|
||||
events::event_context global_context;
|
||||
|
|
Loading…
Add table
Reference in a new issue