Handle path to file with spaces on Windows. Second try.

--HG--
branch : develop
This commit is contained in:
dismine 2014-11-28 17:16:39 +02:00
parent 53be9a337f
commit 95373a0d4a

View file

@ -198,31 +198,28 @@ void VApplication::NewValentina(const QString &fileName)
qCDebug(vApp)<<"Open new detached process."; qCDebug(vApp)<<"Open new detached process.";
if (fileName.isEmpty()) if (fileName.isEmpty())
{ {
qCDebug(vApp)<<"New process without arguments. program ="<<QCoreApplication::applicationFilePath(); qCDebug(vApp)<<"New process without arguments. program ="<<qApp->applicationFilePath();
// Path can contain spaces. // Path can contain spaces.
if (QProcess::startDetached("\""+QCoreApplication::applicationFilePath()+"\"")) if (QProcess::startDetached("\""+qApp->applicationFilePath()+"\""))
{ {
qCDebug(vApp)<<"The process was started successfully."; qCDebug(vApp)<<"The process was started successfully.";
} }
else else
{ {
qCWarning(vApp)<<"The operation timed out or an error occurred."; qCWarning(vApp)<<"Could not run process. The operation timed out or an error occurred.";
} }
} }
else else
{ {
QStringList arguments; const QString run = QString("\"%1\" \"%2\"").arg(qApp->applicationFilePath()).arg(fileName);
arguments << fileName; qCDebug(vApp)<<"New process with arguments. program ="<<run;
qCDebug(vApp)<<"New process with arguments. program ="<<QCoreApplication::applicationFilePath() if(QProcess::startDetached(run))
<<", arguments = "<<arguments;
// Path can contain spaces.
if(QProcess::startDetached("\""+QCoreApplication::applicationFilePath()+"\"", arguments))
{ {
qCDebug(vApp)<<"The process was started successfully."; qCDebug(vApp)<<"The process was started successfully.";
} }
else else
{ {
qCWarning(vApp)<<"The operation timed out or an error occurred."; qCWarning(vApp)<<"Could not run process. The operation timed out or an error occurred.";
} }
} }
} }