qprintdialog_unix.cpp: fix out-of-bounds when cwd is empty.

This happens when the cwd got deleted meanwhile; this warning is printed out:
QFileSystemEngine::currentPath: getcwd() failed
and currentPath() is empty. Not a problem in itself, but qprintdialog
should not assume it's not empty, then.

Change-Id: I5c89992b36ca58b6325ced399cff33aca9efb7ec
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
This commit is contained in:
David Faure 2015-07-31 14:15:56 +02:00
parent 314c83c0c2
commit 109cdeda30

View File

@ -803,7 +803,7 @@ void QUnixPrintWidgetPrivate::applyPrinterProperties()
QString cur = QDir::currentPath();
if (home.at(home.length()-1) != QLatin1Char('/'))
home += QLatin1Char('/');
if (cur.at(cur.length()-1) != QLatin1Char('/'))
if (!cur.isEmpty() && cur.at(cur.length()-1) != QLatin1Char('/'))
cur += QLatin1Char('/');
if (cur.left(home.length()) != home)
cur = home;