From 4956440109ab4177411ef0a1b11691b6d0dc4a28 Mon Sep 17 00:00:00 2001
From: Christian Kandeler <christian.kandeler@nokia.com>
Date: Thu, 28 Oct 2010 10:45:01 +0200
Subject: [PATCH] Maemo: Fix logic deciding on package rebuilding.

The time stamp check must descend into directories.

Task-number: QTCREATORBUG-2920
Reviewed-by: con
---
 .../qt-maemo/maemopackagecreationstep.cpp     | 25 ++++++++++++++++---
 .../qt-maemo/maemopackagecreationstep.h       |  3 +++
 2 files changed, 25 insertions(+), 3 deletions(-)

diff --git a/src/plugins/qt4projectmanager/qt-maemo/maemopackagecreationstep.cpp b/src/plugins/qt4projectmanager/qt-maemo/maemopackagecreationstep.cpp
index 8f782bd792c..2808520c167 100644
--- a/src/plugins/qt4projectmanager/qt-maemo/maemopackagecreationstep.cpp
+++ b/src/plugins/qt4projectmanager/qt-maemo/maemopackagecreationstep.cpp
@@ -56,6 +56,7 @@
 #include <qt4project.h>
 #include <qt4target.h>
 
+#include <QtCore/QDateTime>
 #include <QtCore/QProcess>
 #include <QtCore/QProcessEnvironment>
 #include <QtCore/QRegExp>
@@ -401,9 +402,8 @@ bool MaemoPackageCreationStep::packagingNeeded() const
 
     const int deployableCount = deployables->deployableCount();
     for (int i = 0; i < deployableCount; ++i) {
-        if (packageInfo.lastModified()
-            <= QFileInfo(deployables->deployableAt(i).localFilePath)
-               .lastModified())
+        if (isFileNewerThan(deployables->deployableAt(i).localFilePath,
+                packageInfo.lastModified()))
             return true;
     }
 
@@ -423,6 +423,25 @@ bool MaemoPackageCreationStep::packagingNeeded() const
     return false;
 }
 
+bool MaemoPackageCreationStep::isFileNewerThan(const QString &filePath,
+    const QDateTime &timeStamp) const
+{
+    QFileInfo fileInfo(filePath);
+    if (!fileInfo.exists() || fileInfo.lastModified() >= timeStamp)
+        return true;
+    if (fileInfo.isDir()) {
+        const QStringList dirContents = QDir(filePath)
+            .entryList(QDir::Files | QDir::Dirs | QDir::NoDotAndDotDot);
+        foreach (const QString &curFileName, dirContents) {
+            const QString curFilePath
+                = filePath + QLatin1Char('/') + curFileName;
+            if (isFileNewerThan(curFilePath, timeStamp))
+                return true;
+        }
+    }
+    return false;
+}
+
 QString MaemoPackageCreationStep::packageFilePath() const
 {
     QString error;
diff --git a/src/plugins/qt4projectmanager/qt-maemo/maemopackagecreationstep.h b/src/plugins/qt4projectmanager/qt-maemo/maemopackagecreationstep.h
index ed5fe6efb95..bacd7ec4779 100644
--- a/src/plugins/qt4projectmanager/qt-maemo/maemopackagecreationstep.h
+++ b/src/plugins/qt4projectmanager/qt-maemo/maemopackagecreationstep.h
@@ -45,6 +45,7 @@
 #include <projectexplorer/buildstep.h>
 
 QT_BEGIN_NAMESPACE
+class QDateTime;
 class QFile;
 class QProcess;
 QT_END_NAMESPACE
@@ -112,6 +113,8 @@ private:
     QString targetRoot() const;
     static QString nativePath(const QFile &file);
     bool packagingNeeded() const;
+    bool isFileNewerThan(const QString &filePath,
+        const QDateTime &timeStamp) const;
     void raiseError(const QString &shortMsg,
                     const QString &detailedMsg = QString());
     QString buildDirectory() const;
-- 
GitLab