Skip to content

Commit 7f05c62

Browse files
authored
Merge pull request openscad#5395 from openscad/fix-resource-folder-lookup
Fix resource folder lookup (fixes openscad#5394).
2 parents 0ab2ba2 + 0910d51 commit 7f05c62

File tree

2 files changed

+9
-12
lines changed

2 files changed

+9
-12
lines changed

src/openscad.cc

Lines changed: 9 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@
4242
#include <boost/program_options.hpp>
4343
#include <boost/filesystem.hpp>
4444
#include <boost/optional.hpp>
45+
#include <boost/dll.hpp>
4546

4647
#ifdef ENABLE_CGAL
4748
#include <CGAL/assertions.h>
@@ -66,6 +67,7 @@
6667
#include "platform/PlatformUtils.h"
6768
#include "RenderStatistic.h"
6869
#include "utils/StackCheck.h"
70+
#include "printutils.h"
6971

7072

7173
#ifdef ENABLE_PYTHON
@@ -226,15 +228,15 @@ void set_render_color_scheme(const std::string& color_scheme, const bool exit_if
226228
*/
227229
void localization_init() {
228230
fs::path po_dir(PlatformUtils::resourcePath("locale"));
229-
std::string locale_path(po_dir.string());
231+
const std::string& locale_path(po_dir.string());
230232

231233
if (fs::is_directory(locale_path)) {
232234
setlocale(LC_ALL, "");
233235
bindtextdomain("openscad", locale_path.c_str());
234236
bind_textdomain_codeset("openscad", "UTF-8");
235237
textdomain("openscad");
236238
} else {
237-
LOG("Could not initialize localization.");
239+
LOG("Could not initialize localization (application path is '%1$s').", PlatformUtils::applicationPath());
238240
}
239241
}
240242

@@ -656,15 +658,6 @@ int main(int argc, char **argv)
656658
int rc = 0;
657659
StackCheck::inst();
658660

659-
#ifdef OPENSCAD_QTGUI
660-
{ // Need a dummy app instance to get the application path but it needs to be destroyed before the GUI is launched.
661-
QCoreApplication app(argc, argv);
662-
PlatformUtils::registerApplicationPath(app.applicationDirPath().toLocal8Bit().constData());
663-
}
664-
#else
665-
PlatformUtils::registerApplicationPath(fs::absolute(boost::filesystem::path(argv[0]).parent_path()).generic_string());
666-
#endif
667-
668661
#ifdef Q_OS_MACOS
669662
bool isGuiLaunched = getenv("GUI_LAUNCHED") != nullptr;
670663
auto nslog = [](const Message& msg, void *userdata) {
@@ -675,6 +668,9 @@ int main(int argc, char **argv)
675668
PlatformUtils::ensureStdIO();
676669
#endif
677670

671+
const auto applicationPath = weakly_canonical(boost::dll::program_location().parent_path()).generic_string();
672+
PlatformUtils::registerApplicationPath(applicationPath);
673+
678674
#ifdef ENABLE_CGAL
679675
// Always throw exceptions from CGAL, so we can catch instead of crashing on bad geometry.
680676
CGAL::set_error_behaviour(CGAL::THROW_EXCEPTION);
@@ -929,6 +925,8 @@ int main(int argc, char **argv)
929925
}
930926
}
931927

928+
PRINTDB("Application location detected as %s", applicationPath);
929+
932930
auto cmdlinemode = false;
933931
if (!output_files.empty()) { // cmd-line mode
934932
cmdlinemode = true;

src/platform/PlatformUtils.cc

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,6 @@ static std::string lookupResourcesPath()
5252
const char *searchpath[] = {
5353
RESOURCE_FOLDER("../share/openscad"),
5454
RESOURCE_FOLDER("../../share/openscad"),
55-
"usr/share/openscad", // AppImage, no build suffix
5655
".",
5756
"..",
5857
"../..",

0 commit comments

Comments
 (0)