]> git.sur5r.net Git - minitube/blobdiff - debian/patches/proper-tempfiles
Upload 2.5.1-1 to unstable
[minitube] / debian / patches / proper-tempfiles
index bc4d1251a73549be10220872594e62400a6436a4..f36b48b645f2b3b41bb1ed80584fa6e4e6616a0f 100644 (file)
@@ -6,29 +6,29 @@ Author: Jakob Haufe <sur5r@sur5r.net>
 Bug-Debian: http://bugs.debian.org/644935
 
 diff --git a/src/temporary.cpp b/src/temporary.cpp
-index 362cbd8..bebcd1f 100644
+index 913d244..3e5e89f 100644
 --- a/src/temporary.cpp
 +++ b/src/temporary.cpp
-@@ -1,7 +1,7 @@
- #include "temporary.h"
+@@ -22,51 +22,26 @@ $END_LICENSE */
  #include "constants.h"
+ #include "compatibility/pathsservice.h"
  
 -static QList<QString> paths;
+-#ifdef APP_LINUX
+-static QString userName;
+-#endif
 +static QList<QTemporaryFile*> tempfiles;
- #ifdef Q_WS_X11
- static QString userName;
- #endif
-@@ -10,43 +10,21 @@ Temporary::Temporary() { }
  
- QString Temporary::filename() {
+ Temporary::Temporary() { }
  
--    static const QString tempDir = QDesktopServices::storageLocation(QDesktopServices::TempLocation);
+ QString Temporary::filename() {
+-    static const QString tempDir = Paths::getTempLocation();
 +    QTemporaryFile *tempfile = new QTemporaryFile(QDir::tempPath() + "/" + Constants::UNIX_NAME + "-XXXXXX");
++    tempfiles += tempfile;
  
 -    QString tempFile = tempDir + "/" + Constants::UNIX_NAME + "-" + QString::number(qrand());
-+    tempfiles << tempfile;
--#ifdef Q_WS_X11
+-
+-#ifdef APP_LINUX
 -    if (userName.isNull()) {
 -        userName = QString(getenv("USERNAME"));
 -        if (userName.isEmpty())
@@ -42,7 +42,8 @@ index 362cbd8..bebcd1f 100644
 -
 -    if (QFile::exists(tempFile) && !QFile::remove(tempFile)) {
 -        qDebug() << "Cannot remove temp file" << tempFile;
-+    if (tempfiles.size() > 1) {
++    if (tempfiles.size() > 1)
++    {
 +        QTemporaryFile *removedFile = tempfiles.takeFirst();
 +        delete removedFile;
      }
@@ -63,7 +64,7 @@ index 362cbd8..bebcd1f 100644
  }
  
  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;
 -        }
@@ -71,11 +72,12 @@ index 362cbd8..bebcd1f 100644
 +        delete tempfile;
      }
  }
+
 diff --git a/src/temporary.h b/src/temporary.h
-index 50b9633..0453572 100644
+index de5e24d..b8fbba9 100644
 --- a/src/temporary.h
 +++ b/src/temporary.h
-@@ -3,6 +3,7 @@
+@@ -23,6 +23,7 @@ $END_LICENSE */
  
  #include <QtCore>
  #include <QDesktopServices>