]> git.sur5r.net Git - minitube/blobdiff - src/temporary.cpp
Upload 3.9.3-2 to unstable
[minitube] / src / temporary.cpp
index 3f29d70acc2a230675258c9f8d668c20a60102e4..2bf7fcd4e213d32742906cd93d710fb5e22c69d3 100644 (file)
@@ -21,20 +21,20 @@ $END_LICENSE */
 #include "temporary.h"
 #include "constants.h"
 
-static QList<QString> paths;
-#ifdef Q_WS_X11
+static QVector<QString> paths;
+#ifdef APP_LINUX
 static QString userName;
 #endif
 
 Temporary::Temporary() { }
 
 QString Temporary::filename() {
+    static const QString tempDir = QStandardPaths::writableLocation(QStandardPaths::TempLocation);
 
-    static const QString tempDir = QDesktopServices::storageLocation(QDesktopServices::TempLocation);
+    QString tempFile = tempDir + "/" + Constants::UNIX_NAME + "-" +
+                       QString::number(QRandomGenerator::global()->generate());
 
-    QString tempFile = tempDir + "/" + Constants::UNIX_NAME + "-" + QString::number(qrand());
-
-#ifdef Q_WS_X11
+#ifdef APP_LINUX
     if (userName.isNull()) {
         userName = QString(getenv("USERNAME"));
         if (userName.isEmpty())
@@ -64,7 +64,7 @@ QString Temporary::filename() {
 }
 
 void Temporary::deleteAll() {
-    foreach(QString path, paths) {
+    foreach(const QString &path, paths) {
         if (QFile::exists(path) && !QFile::remove(path)) {
             qDebug() << "Cannot remove temp file" << path;
         }