From dd62bcc824ac95d37cc85a5e354dc24a65597a0e Mon Sep 17 00:00:00 2001
From: Tobias Hunger <tobias.hunger@nokia.com>
Date: Wed, 20 Oct 2010 12:56:06 +0200
Subject: [PATCH] Task: Make sure file contains non-native separators

---
 src/plugins/projectexplorer/copytaskhandler.cpp       | 9 ++++++---
 src/plugins/projectexplorer/gccparser.cpp             | 6 ++++--
 src/plugins/projectexplorer/gnumakeparser.cpp         | 2 +-
 src/plugins/projectexplorer/ldparser.cpp              | 4 +++-
 src/plugins/projectexplorer/linuxiccparser.cpp        | 6 ++++--
 src/plugins/qt4projectmanager/qt-s60/abldparser.cpp   | 6 ++++--
 src/plugins/qt4projectmanager/qt-s60/rvctparser.cpp   | 5 ++++-
 src/plugins/qt4projectmanager/qt-s60/sbsv2parser.cpp  | 2 +-
 src/plugins/qt4projectmanager/qt-s60/winscwparser.cpp | 6 ++++--
 src/plugins/tasklist/tasklistplugin.cpp               | 2 ++
 10 files changed, 33 insertions(+), 15 deletions(-)

diff --git a/src/plugins/projectexplorer/copytaskhandler.cpp b/src/plugins/projectexplorer/copytaskhandler.cpp
index 8694050cd2f..fc2ea22f89f 100644
--- a/src/plugins/projectexplorer/copytaskhandler.cpp
+++ b/src/plugins/projectexplorer/copytaskhandler.cpp
@@ -33,6 +33,7 @@
 
 #include <coreplugin/coreconstants.h>
 
+#include <QtCore/QDir>
 #include <QtGui/QAction>
 #include <QtGui/QApplication>
 #include <QtGui/QClipboard>
@@ -48,16 +49,18 @@ void CopyTaskHandler::handle(const ProjectExplorer::Task &task)
     QString type;
     switch (task.type) {
     case Task::Error:
-        type = tr("error: ", "Task is of type error");
+        //: Task is of type: error
+        type = tr("error: ");
         break;
     case Task::Warning:
-        type = tr("warning: ", "Task is of type warning");
+        //: Task is of type: warning
+        type = tr("warning: ");
         break;
     default:
         break;
     }
 
-    QApplication::clipboard()->setText(task.file + ':' +
+    QApplication::clipboard()->setText(QDir::toNativeSeparators(task.file) + ':' +
                                        QString::number(task.line) + ": "
                                        + type + task.description);
 }
diff --git a/src/plugins/projectexplorer/gccparser.cpp b/src/plugins/projectexplorer/gccparser.cpp
index 00aca2c846b..a997133a929 100644
--- a/src/plugins/projectexplorer/gccparser.cpp
+++ b/src/plugins/projectexplorer/gccparser.cpp
@@ -32,6 +32,8 @@
 #include "taskwindow.h"
 #include "projectexplorerconstants.h"
 
+#include <QtCore/QDir>
+
 using namespace ProjectExplorer;
 
 namespace {
@@ -100,7 +102,7 @@ void GccParser::stdError(const QString &line)
         int lineno = m_regExp.cap(3).toInt();
         Task task(Task::Unknown,
                   m_regExp.cap(8) /* description */,
-                  filename, lineno,
+                  QDir::fromNativeSeparators(filename), lineno,
                   Constants::TASK_CATEGORY_COMPILE);
         if (m_regExp.cap(7) == QLatin1String("warning"))
             task.type = Task::Warning;
@@ -118,7 +120,7 @@ void GccParser::stdError(const QString &line)
     } else if (m_regExpIncluded.indexIn(lne) > -1) {
         emit addTask(Task(Task::Unknown,
                           lne /* description */,
-                          m_regExpIncluded.cap(1) /* filename */,
+                          QDir::fromNativeSeparators(m_regExpIncluded.cap(1)) /* filename */,
                           m_regExpIncluded.cap(3).toInt() /* linenumber */,
                           Constants::TASK_CATEGORY_COMPILE));
         return;
diff --git a/src/plugins/projectexplorer/gnumakeparser.cpp b/src/plugins/projectexplorer/gnumakeparser.cpp
index 0e2664bffff..1cefce09cd0 100644
--- a/src/plugins/projectexplorer/gnumakeparser.cpp
+++ b/src/plugins/projectexplorer/gnumakeparser.cpp
@@ -87,7 +87,7 @@ void GnuMakeParser::stdError(const QString &line)
             m_suppressIssues = true;
             addTask(Task(Task::Error,
                          m_makefileError.cap(3),
-                         m_makefileError.cap(1),
+                         QDir::fromNativeSeparators(m_makefileError.cap(1)),
                          m_makefileError.cap(2).toInt(),
                          Constants::TASK_CATEGORY_BUILDSYSTEM));
         }
diff --git a/src/plugins/projectexplorer/ldparser.cpp b/src/plugins/projectexplorer/ldparser.cpp
index 85a6c566440..f387d553f4c 100644
--- a/src/plugins/projectexplorer/ldparser.cpp
+++ b/src/plugins/projectexplorer/ldparser.cpp
@@ -31,6 +31,8 @@
 #include "projectexplorerconstants.h"
 #include "taskwindow.h"
 
+#include <QtCore/QDir>
+
 using namespace ProjectExplorer;
 
 namespace {
@@ -98,7 +100,7 @@ void LdParser::stdError(const QString &line)
             && !m_regExpLinker.cap(4).startsWith(QLatin1String("(.text+0x")))
             filename = m_regExpLinker.cap(4);
         QString description = m_regExpLinker.cap(8).trimmed();
-        Task task(Task::Error, description, filename, lineno,
+        Task task(Task::Error, description, QDir::fromNativeSeparators(filename), lineno,
                   Constants::TASK_CATEGORY_COMPILE);
         if (m_regExpInFunction.indexIn(description) > -1 ||
             description.startsWith(QLatin1String("At global scope")) ||
diff --git a/src/plugins/projectexplorer/linuxiccparser.cpp b/src/plugins/projectexplorer/linuxiccparser.cpp
index a1038aa32d0..721429a42f8 100644
--- a/src/plugins/projectexplorer/linuxiccparser.cpp
+++ b/src/plugins/projectexplorer/linuxiccparser.cpp
@@ -31,7 +31,8 @@
 #include "ldparser.h"
 #include "taskwindow.h"
 #include "projectexplorerconstants.h"
-#include <QtCore/QDebug>
+
+#include <QtCore/QDir>
 
 using namespace ProjectExplorer;
 
@@ -71,7 +72,8 @@ void LinuxIccParser::stdError(const QString &line)
     if (m_expectFirstLine  && m_firstLine.indexIn(line) != -1) {
         // Clear out old task
         m_temporary = ProjectExplorer::Task(Task::Unknown, m_firstLine.cap(6).trimmed(),
-                                            m_firstLine.cap(1), m_firstLine.cap(2).toInt(),
+                                            QDir::fromNativeSeparators(m_firstLine.cap(1)),
+                                            m_firstLine.cap(2).toInt(),
                                             QLatin1String(Constants::TASK_CATEGORY_COMPILE));
         QString category = m_firstLine.cap(4);
         if (category == QLatin1String("error"))
diff --git a/src/plugins/qt4projectmanager/qt-s60/abldparser.cpp b/src/plugins/qt4projectmanager/qt-s60/abldparser.cpp
index 4fbf4d0c782..8be4c3f7fb8 100644
--- a/src/plugins/qt4projectmanager/qt-s60/abldparser.cpp
+++ b/src/plugins/qt4projectmanager/qt-s60/abldparser.cpp
@@ -32,6 +32,8 @@
 #include <projectexplorer/projectexplorerconstants.h>
 #include <projectexplorer/taskwindow.h>
 
+#include <QtCore/QDir>
+
 using namespace Qt4ProjectManager;
 using namespace ProjectExplorer;
 using namespace ProjectExplorer::Constants;
@@ -73,7 +75,7 @@ void AbldParser::stdOutput(const QString &line)
 
     if (m_perlIssue.indexIn(lne) > -1) {
         m_waitingForStdOutContinuation = true;
-        m_currentFile = m_perlIssue.cap(2);
+        m_currentFile = QDir::fromNativeSeparators(m_perlIssue.cap(2));
         m_currentLine = m_perlIssue.cap(3).toInt();
 
         Task task(Task::Unknown,
@@ -143,7 +145,7 @@ void AbldParser::stdError(const QString &line)
     }
 
     if (lne.startsWith(QLatin1String("MMPFILE \""))) {
-        m_currentFile = lne.mid(9, lne.size() - 10);
+        m_currentFile = QDir::fromNativeSeparators(lne.mid(9, lne.size() - 10));
         m_waitingForStdErrContinuation = false;
         return;
     }
diff --git a/src/plugins/qt4projectmanager/qt-s60/rvctparser.cpp b/src/plugins/qt4projectmanager/qt-s60/rvctparser.cpp
index cde0deeee40..1dd868e1bc1 100644
--- a/src/plugins/qt4projectmanager/qt-s60/rvctparser.cpp
+++ b/src/plugins/qt4projectmanager/qt-s60/rvctparser.cpp
@@ -31,6 +31,8 @@
 #include <projectexplorer/projectexplorerconstants.h>
 #include <projectexplorer/taskwindow.h>
 
+#include <QtCore/QDir>
+
 using namespace ProjectExplorer;
 using namespace ProjectExplorer::Constants;
 using namespace Qt4ProjectManager;
@@ -80,7 +82,8 @@ void RvctParser::stdError(const QString &line)
 
        m_task = new Task(Task::Unknown,
                          m_warningOrError.cap(5) /* description */,
-                         m_warningOrError.cap(1) /* file */, m_warningOrError.cap(2).toInt() /* line */,
+                         QDir::fromNativeSeparators(m_warningOrError.cap(1)) /* file */,
+                         m_warningOrError.cap(2).toInt() /* line */,
                          TASK_CATEGORY_COMPILE);
        if (m_warningOrError.cap(4) == "Warning")
            m_task->type = Task::Warning;
diff --git a/src/plugins/qt4projectmanager/qt-s60/sbsv2parser.cpp b/src/plugins/qt4projectmanager/qt-s60/sbsv2parser.cpp
index fb9f04fc64a..5f60d299715 100644
--- a/src/plugins/qt4projectmanager/qt-s60/sbsv2parser.cpp
+++ b/src/plugins/qt4projectmanager/qt-s60/sbsv2parser.cpp
@@ -65,7 +65,7 @@ void SbsV2Parser::stdOutput(const QString &line)
 {
     // Eat most output!
     if (line.startsWith(QLatin1String("sbs: build log in "))) {
-        QString logfile = line.mid(18).trimmed();
+        QString logfile = QDir::fromNativeSeparators(line.mid(18).trimmed());
         parseLogFile(logfile);
         addTask(ProjectExplorer::Task(Task::Unknown, tr("SBSv2 build log"),
                                       logfile, -1,
diff --git a/src/plugins/qt4projectmanager/qt-s60/winscwparser.cpp b/src/plugins/qt4projectmanager/qt-s60/winscwparser.cpp
index 9d1522fe98e..0d04793f65b 100644
--- a/src/plugins/qt4projectmanager/qt-s60/winscwparser.cpp
+++ b/src/plugins/qt4projectmanager/qt-s60/winscwparser.cpp
@@ -31,6 +31,8 @@
 #include <projectexplorer/projectexplorerconstants.h>
 #include <projectexplorer/taskwindow.h>
 
+#include <QtCore/QDir>
+
 using namespace Qt4ProjectManager;
 using namespace ProjectExplorer;
 using namespace ProjectExplorer::Constants;
@@ -54,7 +56,7 @@ void WinscwParser::stdOutput(const QString &line)
     if (m_compilerProblem.indexIn(lne) > -1) {
         Task task(Task::Error,
                   m_compilerProblem.cap(3) /* description */,
-                  m_compilerProblem.cap(1) /* filename */,
+                  QDir::fromNativeSeparators(m_compilerProblem.cap(1)) /* filename */,
                   m_compilerProblem.cap(2).toInt() /* linenumber */,
                   TASK_CATEGORY_COMPILE);
         if (task.description.startsWith(QLatin1String("warning: "))) {
@@ -74,7 +76,7 @@ void WinscwParser::stdError(const QString &line)
     if (m_linkerProblem.indexIn(lne) > -1) {
         emit addTask(Task(Task::Error,
                           m_linkerProblem.cap(2) /* description */,
-                          m_linkerProblem.cap(1) /* filename */,
+                          QDir::fromNativeSeparators(m_linkerProblem.cap(1)) /* filename */,
                           -1 /* linenumber */,
                           TASK_CATEGORY_COMPILE));
         return;
diff --git a/src/plugins/tasklist/tasklistplugin.cpp b/src/plugins/tasklist/tasklistplugin.cpp
index f3573828bb4..4ed60440d8a 100644
--- a/src/plugins/tasklist/tasklistplugin.cpp
+++ b/src/plugins/tasklist/tasklistplugin.cpp
@@ -41,6 +41,7 @@
 #include <projectexplorer/task.h>
 #include <projectexplorer/taskhub.h>
 
+#include <QtCore/QDir>
 #include <QtCore/QStringList>
 #include <QtCore/QtPlugin>
 
@@ -105,6 +106,7 @@ public:
                 description = chunks.at(3);
             }
             if (!file.isEmpty()) {
+                file = QDir::fromNativeSeparators(file);
                 QFileInfo fi(file);
                 if (fi.isRelative() && context) {
                     QString fullPath = context->projectDirectory() + '/' + file;
-- 
GitLab