From 4245b4ab441e25754a61d7929d6287ad493ae88d Mon Sep 17 00:00:00 2001
From: con <qtc-committer@nokia.com>
Date: Mon, 5 Jul 2010 13:22:46 +0200
Subject: [PATCH] Pick up the newest debugging helper from the possible
 locations.

Otherwise "rebuilding" the debugging helper doesn't necessarily lead to
Qt Creator picking up the new one (some of the locations can be
read-only).

Reviewed-by: dt
---
 src/plugins/projectexplorer/debugginghelper.cpp | 15 ++++++++++-----
 1 file changed, 10 insertions(+), 5 deletions(-)

diff --git a/src/plugins/projectexplorer/debugginghelper.cpp b/src/plugins/projectexplorer/debugginghelper.cpp
index 9c091557c01..848c2a404f9 100644
--- a/src/plugins/projectexplorer/debugginghelper.cpp
+++ b/src/plugins/projectexplorer/debugginghelper.cpp
@@ -116,20 +116,25 @@ QString DebuggingHelperLibrary::debuggingHelperLibraryByInstallData(const QStrin
     if (!Core::ICore::instance())
         return QString();
     const QString dumperSourcePath = Core::ICore::instance()->resourcePath() + QLatin1String("/gdbmacros/");
-    QDateTime lastModified = QFileInfo(dumperSourcePath + "gdbmacros.cpp").lastModified();
+    QDateTime sourcesModified = QFileInfo(dumperSourcePath + "gdbmacros.cpp").lastModified();
     // We pretend that the lastmodified of gdbmacros.cpp is 5 minutes before what the file system says
     // Because afer a installation from the package the modified dates of gdbmacros.cpp
     // and the actual library are close to each other, but not deterministic in one direction
-    lastModified = lastModified.addSecs(-300);
+    sourcesModified = sourcesModified.addSecs(-300);
 
+    // look for the newest helper library in the different locations
+    QString newestHelper;
+    QDateTime newestHelperModified = sourcesModified; // prevent using one that's older than the sources
     QFileInfo fileInfo;
     foreach(const QString &directory, debuggingHelperLibraryDirectories(qtInstallData)) {
         if (getHelperFileInfoFor(directory, &fileInfo)) {
-            if (fileInfo.lastModified() >= lastModified)
-                return fileInfo.filePath();
+            if (fileInfo.lastModified() > newestHelperModified) {
+                newestHelper = fileInfo.filePath();
+                newestHelperModified = fileInfo.lastModified();
+            }
         }
     }
-    return QString();
+    return newestHelper;
 }
 
 // Copy helper source files to a target directory, replacing older files.
-- 
GitLab