From a218869770c1b9f567e48c90867f9802463ad318 Mon Sep 17 00:00:00 2001 From: Henner Zeller Date: Tue, 29 Oct 2013 20:55:32 -0700 Subject: [PATCH] Invocation of openscad with an absolute path failed: ./openscad /home/username/foo.scad .. because the curent working directory was always prepended; so internally, it attempted to open $PWD + /home/username/foo.scad Use platform aware QDir functionality to only prepend the absolute current working directory prefix, if the given path is relative. --- src/openscad.cc | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/src/openscad.cc b/src/openscad.cc index 1e08a519..6bbaedb6 100644 --- a/src/openscad.cc +++ b/src/openscad.cc @@ -450,6 +450,13 @@ int cmdline(const char *deps_output_file, const std::string &filename, Camera &c #include #include +// Only if "fileName" is not absolute, prepend the "absoluteBase". +static QString assemblePath(const fs::path& absoluteBase, + const string& fileName) { + return QDir(QString::fromStdString((const string&) absoluteBase)) + .absoluteFilePath(QString::fromStdString(fileName)); +} + bool QtUseGUI() { #ifdef Q_WS_X11 @@ -521,11 +528,11 @@ int gui(vector &inputFiles, const fs::path &original_path, int argc, cha if (!inputFiles.size()) inputFiles.push_back(""); #ifdef ENABLE_MDI BOOST_FOREACH(const string &infile, inputFiles) { - new MainWindow(QString::fromLocal8Bit(infile.empty() ? infile.c_str() : boosty::stringy(original_path / infile).c_str())); + new MainWindow(assemblePath(original_path, infile)); } app.connect(&app, SIGNAL(lastWindowClosed()), &app, SLOT(quit())); #else - MainWindow *m = new MainWindow(QString::fromLocal8Bit(inputFiles[0].empty() ? inputFiles[0].c_str() : boosty::stringy(original_path / inputFiles[0]).c_str())); + MainWindow *m = new MainWindow(assemblePath(original_path, inputFiles[0])); app.connect(m, SIGNAL(destroyed()), &app, SLOT(quit())); #endif return app.exec();