Handle path to file with spaces on Windows.

--HG--
branch : develop
This commit is contained in:
dismine 2014-11-26 20:34:43 +02:00
parent 69a85e7ef2
commit 2f74c280ac

View file

@ -190,19 +190,35 @@ VApplication::~VApplication()
void VApplication::NewValentina(const QString &fileName) void VApplication::NewValentina(const QString &fileName)
{ {
qCDebug(vApp)<<"Open new detached process."; qCDebug(vApp)<<"Open new detached process.";
QProcess *v = new QProcess();
QStringList arguments;
arguments << fileName;
if (fileName.isEmpty()) if (fileName.isEmpty())
{ {
v->startDetached(QCoreApplication::applicationFilePath()); qCDebug(vApp)<<"New process without arguments. program ="<<QCoreApplication::applicationFilePath();
// Path can contain spaces.
if (QProcess::startDetached("\""+QCoreApplication::applicationFilePath()+"\""))
{
qCDebug(vApp)<<"The process was started successfully.";
}
else
{
qCWarning(vApp)<<"The operation timed out or an error occurred.";
}
} }
else else
{ {
v->startDetached(QCoreApplication::applicationFilePath(), arguments); QStringList arguments;
arguments << fileName;
qCDebug(vApp)<<"New process with arguments. program ="<<QCoreApplication::applicationFilePath()
<<", arguments = "<<arguments;
// Path can contain spaces.
if(QProcess::startDetached("\""+QCoreApplication::applicationFilePath()+"\"", arguments))
{
qCDebug(vApp)<<"The process was started successfully.";
}
else
{
qCWarning(vApp)<<"The operation timed out or an error occurred.";
}
} }
delete v;
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------