OSDN Git Service

C++ editor: Normalize line endings for find usages
authorLeandro Melo <leandro.melo@nokia.com>
Tue, 31 May 2011 08:58:23 +0000 (10:58 +0200)
committerErik Verbruggen <erik.verbruggen@nokia.com>
Tue, 31 May 2011 10:06:27 +0000 (12:06 +0200)
Find usages and related rely on functions that assume \n as line
ending. This is true for the preprocessed files, but not for the
original sources.

Change-Id: I61b7e05c0116504d11c7df4b1aa10d519b705336
Reviewed-on: http://codereview.qt.nokia.com/260
Reviewed-by: Qt Sanity Bot <qt_sanity_bot@ovi.com>
Reviewed-by: Erik Verbruggen <erik.verbruggen@nokia.com>
src/plugins/cpptools/cppfindreferences.cpp
src/plugins/cpptools/uicodecompletionsupport.cpp

index dfc519e..1d8911f 100644 (file)
@@ -79,7 +79,7 @@ static QString getSource(const QString &fileName,
         return workingCopy.source(fileName);
     } else {
         Utils::FileReader reader;
-        if (!reader.fetch(fileName)) // ### FIXME error reporting
+        if (!reader.fetch(fileName, QFile::Text)) // ### FIXME error reporting
             return QString();
 
         return QString::fromLocal8Bit(reader.data()); // ### FIXME encoding
index b72b682..f7e14c8 100644 (file)
@@ -68,7 +68,7 @@ void UiCodeModelSupport::init() const
     QDateTime uiHeaderTime = uiHeaderFileInfo.exists() ? uiHeaderFileInfo.lastModified() : QDateTime();
     if (uiHeaderTime.isValid() && (uiHeaderTime > sourceTime)) {
         QFile file(m_fileName);
-        if (file.open(QFile::ReadOnly)) {
+        if (file.open(QFile::ReadOnly | QFile::Text)) {
             if (debug)
                 qDebug()<<"ui*h file is more recent then source file, using information from ui*h file"<<m_fileName;
             QTextStream stream(&file);
@@ -81,7 +81,7 @@ void UiCodeModelSupport::init() const
     if (debug)
         qDebug()<<"ui*h file not found, or not recent enough, trying to create it on the fly";
     QFile file(m_sourceName);
-    if (file.open(QFile::ReadOnly)) {
+    if (file.open(QFile::ReadOnly | QFile::Text)) {
         QTextStream stream(&file);
         const QString contents = stream.readAll();
         if (runUic(contents)) {
@@ -189,7 +189,7 @@ void UiCodeModelSupport::updateFromBuild()
                 qDebug()<<"found ui*h updating from it";
 
             QFile file(m_fileName);
-            if (file.open(QFile::ReadOnly)) {
+            if (file.open(QFile::ReadOnly | QFile::Text)) {
                 QTextStream stream(&file);
                 m_contents = stream.readAll().toUtf8();
                 m_cacheTime = uiHeaderTime;