From 3e041850f7ec39b0cba51dc4bc20efe64b24eef4 Mon Sep 17 00:00:00 2001 From: wmayer Date: Fri, 14 Oct 2016 18:01:11 +0200 Subject: [PATCH] when using --single-instance option make relative path names absolute --- src/Gui/Application.cpp | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/src/Gui/Application.cpp b/src/Gui/Application.cpp index 913131ce44b4..c5fb531f1678 100644 --- a/src/Gui/Application.cpp +++ b/src/Gui/Application.cpp @@ -1537,9 +1537,19 @@ void Application::runApplication(void) if (it != cfg.end() && mainApp.isRunning()) { // send the file names to be opened to the server application so that this // opens them + QDir cwd = QDir::current(); std::list files = App::Application::getCmdLineFiles(); for (std::list::iterator jt = files.begin(); jt != files.end(); ++jt) { - QByteArray msg(jt->c_str(), static_cast(jt->size())); + QString fn = QString::fromUtf8(jt->c_str(), static_cast(jt->size())); + QFileInfo fi(fn); + // if path name is relative make it absolute because the running instance + // cannot determine the full path when trying to load the file + if (fi.isRelative()) { + fn = cwd.absoluteFilePath(fn); + fn = QDir::cleanPath(fn); + } + + QByteArray msg = fn.toUtf8(); msg.prepend("OpenFile:"); if (!mainApp.sendMessage(msg)) { qWarning("Failed to send message to server");