Merge lp:~widelands-dev/widelands/bug-1703833-catch-missing-datadir into lp:widelands

Proposed by GunChleoc
Status: Merged
Merged at revision: 8760
Proposed branch: lp:~widelands-dev/widelands/bug-1703833-catch-missing-datadir
Merge into: lp:widelands
Diff against target: 30 lines (+10/-3)
1 file modified
src/wlapplication.cc (+10/-3)
To merge this branch: bzr merge lp:~widelands-dev/widelands/bug-1703833-catch-missing-datadir
Reviewer Review Type Date Requested Status
Notabilis diff, testing Approve
Review via email: mp+349629@code.launchpad.net

Commit message

Exit gracefully if user specifies a datadir that doesn't exist

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

Diff is mostly looking good. Passing a non-existing directory to the fixed code (see diff) worked fine.

review: Needs Fixing (diff, testing)
Revision history for this message
Notabilis (notabilis27) wrote :

Looking good now, thanks.

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

Thanks!

@bunnybot merge

Revision history for this message
bunnybot (widelandsofficial) wrote :

Continuous integration builds have changed state:

Travis build 3677. State: failed. Details: https://travis-ci.org/widelands/widelands/builds/405393952.
Appveyor build 3476. State: failed. Details: https://ci.appveyor.com/project/widelands-dev/widelands/build/_widelands_dev_widelands_bug_1703833_catch_missing_datadir-3476.

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 3677. State: failed. Details: https://travis-ci.org/widelands/widelands/builds/405393952.

Revision history for this message
bunnybot (widelandsofficial) wrote :

Continuous integration builds have changed state:

Travis build 3690. State: passed. Details: https://travis-ci.org/widelands/widelands/builds/405785266.
Appveyor build 3489. State: success. Details: https://ci.appveyor.com/project/widelands-dev/widelands/build/_widelands_dev_widelands_bug_1703833_catch_missing_datadir-3489.

Revision history for this message
GunChleoc (gunchleoc) wrote :

@bunnybot merge

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'src/wlapplication.cc'
2--- src/wlapplication.cc 2018-07-07 19:20:22 +0000
3+++ src/wlapplication.cc 2018-07-19 11:13:32 +0000
4@@ -157,7 +157,9 @@
5 // http://pubs.opengroup.org/onlinepubs/009695399/functions/realpath.html
6 char* rp = realpath(path.c_str(), buffer);
7 log("Realpath: %s\n", rp);
8- assert(rp);
9+ if (!rp) {
10+ throw wexception("Unable to get absolute path for %s", path.c_str());
11+ }
12 return std::string(rp);
13 #else
14 return path;
15@@ -936,8 +938,13 @@
16 get_executable_directory() + FileSystem::file_separator() + INSTALL_DATADIR;
17 }
18 if (!is_absolute_path(datadir_)) {
19- datadir_ = absolute_path_if_not_windows(FileSystem::get_working_directory() +
20- FileSystem::file_separator() + datadir_);
21+ try {
22+ datadir_ = absolute_path_if_not_windows(FileSystem::get_working_directory() +
23+ FileSystem::file_separator() + datadir_);
24+ } catch (const WException& e) {
25+ log("Error parsing datadir: %s\n", e.what());
26+ exit(1);
27+ }
28 }
29 if (commandline_.count("datadir_for_testing")) {
30 datadir_for_testing_ = commandline_["datadir_for_testing"];

Subscribers

People subscribed via source and target branches

to status/vote changes: