diff options
author | Henner Zeller <h.zeller@acm.org> | 2013-10-30 03:55:32 (GMT) |
---|---|---|
committer | Henner Zeller <h.zeller@acm.org> | 2013-10-30 03:55:32 (GMT) |
commit | a218869770c1b9f567e48c90867f9802463ad318 (patch) | |
tree | 7fb379b1fb2b5e342af8a366a92a4e91243f8a5c /src/openscad.cc | |
parent | 8aa749f8b3bd0d6dd2cf4d2357a688319689432f (diff) |
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.
Diffstat (limited to 'src/openscad.cc')
-rw-r--r-- | src/openscad.cc | 11 |
1 files changed, 9 insertions, 2 deletions
diff --git a/src/openscad.cc b/src/openscad.cc index 1e08a51..6bbaedb 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 <QString> #include <QDir> +// 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<string> &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(); |