Fix temporary files stored in current folder on first start.

If Rockbox Utility has no configuration file on the machine updateSettings()
will overwrite the global cache folder settings with an empty string before the
value is set properly by the user confirming the configuration dialog.  QDir()
getting an empty string will result in the current working directory getting
used, and thus the temporary files ending up there.

On Windows most users are unlikely to have noticed this since running the
executable from within the distribution zip file will make Windows execute it
in the systems temporary path.

Change-Id: I7724a82af403955786798c7380198086837e128f
This commit is contained in:
Dominik Riebeling 2013-06-09 16:41:45 +02:00
parent 9edc63b0d4
commit 280a0eb27e

View file

@ -72,6 +72,8 @@ RbUtilQt::RbUtilQt(QWidget *parent) : QMainWindow(parent)
absolutePath = qApp->applicationDirPath();
QString c = RbSettings::value(RbSettings::CachePath).toString();
HttpGet::setGlobalCache(c.isEmpty() ? QDir::tempPath() : c);
HttpGet::setGlobalUserAgent("rbutil/"VERSION);
HttpGet::setGlobalProxy(proxy());
// init startup & autodetection
@ -113,12 +115,9 @@ RbUtilQt::RbUtilQt(QWidget *parent) : QMainWindow(parent)
#endif
#if !defined(Q_OS_WIN32) && !defined(Q_OS_MACX)
/* eject funtionality is only implemented on W32 right now. */
/* eject funtionality is not available on Linux right now. */
ui.buttonEject->setEnabled(false);
#endif
QString c = RbSettings::value(RbSettings::CachePath).toString();
if(c.isEmpty()) c = QDir::tempPath();
HttpGet::setGlobalCache(c);
updateDevice();
downloadInfo();
@ -314,8 +313,9 @@ void RbUtilQt::updateSettings()
qDebug() << "[RbUtil] updating current settings";
updateDevice();
manual->updateManual();
QString c = RbSettings::value(RbSettings::CachePath).toString();
HttpGet::setGlobalCache(c.isEmpty() ? QDir::tempPath() : c);
HttpGet::setGlobalProxy(proxy());
HttpGet::setGlobalCache(RbSettings::value(RbSettings::CachePath).toString());
if(RbSettings::value(RbSettings::RbutilVersion) != PUREVERSION) {
QApplication::processEvents();