when using --single-instance option make relative path names absolute
This commit is contained in:
parent
d515fbc05a
commit
3e041850f7
|
@ -1537,9 +1537,19 @@ void Application::runApplication(void)
|
||||||
if (it != cfg.end() && mainApp.isRunning()) {
|
if (it != cfg.end() && mainApp.isRunning()) {
|
||||||
// send the file names to be opened to the server application so that this
|
// send the file names to be opened to the server application so that this
|
||||||
// opens them
|
// opens them
|
||||||
|
QDir cwd = QDir::current();
|
||||||
std::list<std::string> files = App::Application::getCmdLineFiles();
|
std::list<std::string> files = App::Application::getCmdLineFiles();
|
||||||
for (std::list<std::string>::iterator jt = files.begin(); jt != files.end(); ++jt) {
|
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:");
|
msg.prepend("OpenFile:");
|
||||||
if (!mainApp.sendMessage(msg)) {
|
if (!mainApp.sendMessage(msg)) {
|
||||||
qWarning("Failed to send message to server");
|
qWarning("Failed to send message to server");
|
||||||
|
|
Loading…
Reference in New Issue
Block a user