Skip to content

Commit

Permalink
when using --single-instance option make relative path names absolute
Browse files Browse the repository at this point in the history
  • Loading branch information
wwmayer committed Oct 14, 2016
1 parent d515fbc commit 3e04185
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion src/Gui/Application.cpp
Expand Up @@ -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<std::string> files = App::Application::getCmdLineFiles();
for (std::list<std::string>::iterator jt = files.begin(); jt != files.end(); ++jt) {
QByteArray msg(jt->c_str(), static_cast<int>(jt->size()));
QString fn = QString::fromUtf8(jt->c_str(), static_cast<int>(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");
Expand Down

0 comments on commit 3e04185

Please sign in to comment.