aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--tests/testcodeinjection.cpp3
-rw-r--r--typesystem.cpp4
2 files changed, 5 insertions, 2 deletions
diff --git a/tests/testcodeinjection.cpp b/tests/testcodeinjection.cpp
index e3619a202..b056ead83 100644
--- a/tests/testcodeinjection.cpp
+++ b/tests/testcodeinjection.cpp
@@ -34,6 +34,7 @@ void TestCodeInjections::testReadFileUtf8()
QString xmlCode = "\
<typesystem package=\"Foo\"> \
<value-type name='A'> \
+ <conversion-rule file='"+filePath+"/utf8code.txt'/>\
<inject-code class='target' file='"+filePath+"/utf8code.txt' />\
</value-type>\
<value-type name='A::B'/> \
@@ -45,6 +46,8 @@ void TestCodeInjections::testReadFileUtf8()
QString code = classA->typeEntry()->codeSnips().first().code();
QString utf8Data = QString::fromUtf8("\xC3\xA1\xC3\xA9\xC3\xAD\xC3\xB3\xC3\xBA");
QVERIFY(code.indexOf(utf8Data) != -1);
+ code = classA->typeEntry()->conversionRule();
+ QVERIFY(code.indexOf(utf8Data) != -1);
}
QTEST_APPLESS_MAIN(TestCodeInjections)
diff --git a/typesystem.cpp b/typesystem.cpp
index 220d5af1e..89dfd4768 100644
--- a/typesystem.cpp
+++ b/typesystem.cpp
@@ -1045,8 +1045,8 @@ bool Handler::startElement(const QString &, const QString &n,
if (m_generate != TypeEntry::GenerateForSubclass
&& m_generate != TypeEntry::GenerateNothing) {
QFile conversionSource(sourceFile);
- if (conversionSource.open(QIODevice::ReadOnly)) {
- topElement.entry->setConversionRule(conversionSource.readAll());
+ if (conversionSource.open(QIODevice::ReadOnly | QIODevice::Text)) {
+ topElement.entry->setConversionRule(QString::fromUtf8(conversionSource.readAll()));
} else {
ReportHandler::warning("File containing conversion code for "
+ topElement.entry->name()