GTK: don't crash if argv[0]=="solvespace".
parent
a98cdeeb16
commit
251948bdbd
|
@ -1505,6 +1505,7 @@ const void *LoadResource(const std::string &name, size_t *size) {
|
||||||
path = (UNIX_DATADIR "/") + name;
|
path = (UNIX_DATADIR "/") + name;
|
||||||
if(stat(path.c_str(), &st)) {
|
if(stat(path.c_str(), &st)) {
|
||||||
ssassert(errno == ENOENT, "Unexpected stat() error");
|
ssassert(errno == ENOENT, "Unexpected stat() error");
|
||||||
|
ssassert(!resource_dir.empty(), "Expected local resource directory to be set");
|
||||||
path = resource_dir + "/" + name;
|
path = resource_dir + "/" + name;
|
||||||
ssassert(!stat(path.c_str(), &st), "Cannot find resource");
|
ssassert(!stat(path.c_str(), &st), "Cannot find resource");
|
||||||
}
|
}
|
||||||
|
@ -1585,10 +1586,13 @@ int main(int argc, char** argv) {
|
||||||
ambiguous. */
|
ambiguous. */
|
||||||
gtk_disable_setlocale();
|
gtk_disable_setlocale();
|
||||||
|
|
||||||
resource_dir = argv[0]; // .../src/solvespace
|
/* Are we running from a build directory, as opposed to a global install? */
|
||||||
resource_dir.erase(resource_dir.rfind('/'));
|
if(std::string(argv[0]).find('/') != std::string::npos) {
|
||||||
resource_dir.erase(resource_dir.rfind('/'));
|
resource_dir = argv[0]; // .../src/solvespace
|
||||||
resource_dir += "/res"; // .../res
|
resource_dir.erase(resource_dir.rfind('/'));
|
||||||
|
resource_dir.erase(resource_dir.rfind('/'));
|
||||||
|
resource_dir += "/res"; // .../res
|
||||||
|
}
|
||||||
|
|
||||||
Gtk::Main main(argc, argv);
|
Gtk::Main main(argc, argv);
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue