Commit f7c68f6b authored by Erik Verbruggen's avatar Erik Verbruggen
Browse files

C++: change working-copy to work on UTF-8 encoded QByteArrays.



These not only take less space than UTF-16 encoded QStrings, but due to
the caching in the CppEditorSupport also take less time to build.

This patch also fixes a number of possible encoding issues, where files
and constant strings were (falsely) assumed to be UTF-8.

Change-Id: Ib6f91c9a94ebed5b5dfbd4eb2998825c62c72784
Reviewed-by: default avatarNikolai Kosjar <nikolai.kosjar@digia.com>
Reviewed-by: default avatarhjk <hjk121@nokiamail.com>
parent eebb1dfc
......@@ -221,8 +221,11 @@ void GenericProject::parseProject(RefreshOptions options)
m_defines.clear();
QFile configFile(configFileName());
if (configFile.open(QFile::ReadOnly))
m_defines = configFile.readAll();
if (configFile.open(QFile::ReadOnly)) {
// convert from local/file encoding to UTF-8
QTextStream configStream(&configFile);
m_defines = configStream.readAll().toUtf8();
}
}
if (options & Files)
......
......@@ -223,14 +223,15 @@ QByteArray AbstractMsvcToolChain::msvcPredefinedMacros(const QStringList cxxflag
Q_UNUSED(cxxflags);
Q_UNUSED(env);
QByteArray predefinedMacros = "#define __MSVCRT__\n"
static const QByteArray predefinedMacros(
"#define __MSVCRT__\n"
"#define __w64\n"
"#define __int64 long long\n"
"#define __int32 long\n"
"#define __int16 short\n"
"#define __int8 char\n"
"#define __ptr32\n"
"#define __ptr64\n";
"#define __ptr64\n");
return predefinedMacros;
}
......
......@@ -123,14 +123,14 @@ void UiCodeModelSupport::init() const
if (debug)
qDebug()<<"uic run wasn't succesfull";
m_cacheTime = QDateTime ();
m_contents = QByteArray();
m_contents.clear();
m_state = FINISHED;
return;
}
} else {
if (debug)
qDebug()<<"Could open "<<m_uiFileName<<"needed for the cpp model";
m_contents = QByteArray();
m_contents.clear();
m_state = FINISHED;
}
}
......@@ -296,7 +296,10 @@ bool UiCodeModelSupport::finishProcess() const
if (m_state != RUNNING) // waitForFinished can recurse into finishProcess
return true;
m_contents = m_process.readAllStandardOutput();
// As far as I can discover in the UIC sources, it writes out local 8-bit encoding. The
// conversion below is to normalize both the encoding, and the line terminators.
QString normalized = QString::fromLocal8Bit(m_process.readAllStandardOutput());
m_contents = normalized.toUtf8();
m_cacheTime = QDateTime::currentDateTime();
if (debug)
qDebug() << "ok" << m_contents.size() << "bytes.";
......
......@@ -59,6 +59,7 @@ public:
~UiCodeModelSupport();
void setHeaderFileName(const QString &name);
/// \returns the contents encoded in UTF-8.
QByteArray contents() const;
QString uiFileName() const; // The .ui-file
QString fileName() const; // The header file
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment