diff options
author | raidsan <raidsan@gmail.com> | 2012-04-14 13:29:03 +0800 |
---|---|---|
committer | Eike Ziller <eike.ziller@digia.com> | 2012-10-05 13:38:08 +0200 |
commit | 6b5bccd08e7f37bd4be322c0284d60e30ccece90 (patch) | |
tree | 3cc510a5fad7df996200eecf696e0670979fa64f | |
parent | 9de676ce0393be1ee0d5abaae860a91ec113e567 (diff) | |
download | qt-creator-6b5bccd08e7f37bd4be322c0284d60e30ccece90.tar.gz |
"Find Usages" and "Refactor" may decode error.
Task-number: QTCREATORBUG-7204
Change-Id: I6ce82c701246ddac9cadcdd22ef994b0086ce8f7
Reviewed-by: Andre Hartmann <aha_1980@gmx.de>
Reviewed-by: Eike Ziller <eike.ziller@digia.com>
-rw-r--r-- | src/plugins/cpptools/cppfindreferences.cpp | 16 |
1 files changed, 11 insertions, 5 deletions
diff --git a/src/plugins/cpptools/cppfindreferences.cpp b/src/plugins/cpptools/cppfindreferences.cpp index 5d5b6795a7..2fa5ed2ed7 100644 --- a/src/plugins/cpptools/cppfindreferences.cpp +++ b/src/plugins/cpptools/cppfindreferences.cpp @@ -65,6 +65,7 @@ #include <QDir> #include <QApplication> #include <utils/runextensions.h> +#include <utils/textfileformat.h> #include <functional> @@ -77,11 +78,16 @@ static QString getSource(const QString &fileName, if (workingCopy.contains(fileName)) { return workingCopy.source(fileName); } else { - Utils::FileReader reader; - if (!reader.fetch(fileName, QFile::Text)) // ### FIXME error reporting - return QString(); - - return QString::fromLocal8Bit(reader.data()); // ### FIXME encoding + QString fileContents; + Utils::TextFileFormat format; + QString error; + QTextCodec *defaultCodec = Core::EditorManager::instance()->defaultTextCodec(); + Utils::TextFileFormat::ReadResult result = Utils::TextFileFormat::readFile( + fileName, defaultCodec, &fileContents, &format, &error); + if (result != Utils::TextFileFormat::ReadSuccess) + qWarning() << "Could not read " << fileName << ". Error: " << error; + + return fileContents; } } |