summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTomi Korpipaa <tomi.korpipaa@qt.io>2019-02-07 09:38:37 +0200
committerTomi Korpipää <tomi.korpipaa@qt.io>2019-02-07 09:01:41 +0000
commit74b2def81b8f3f52406359b5f68eef4e440e053e (patch)
tree119cf8da4bb03b7836072e7290f2be7e6e73190f
parent688327ec69933d585d33e383593ea8e59ffe2437 (diff)
Fix noncanonical uia/uip file saving
Task-number: QT3DS-2960 Change-Id: I0c994b9712a65a529fe269dbab9227ce1a3f199e Reviewed-by: Janne Kangas <janne.kangas@qt.io> Reviewed-by: Miikka Heikkinen <miikka.heikkinen@qt.io>
-rw-r--r--src/Authoring/Studio/Application/StudioApp.cpp3
-rw-r--r--src/Authoring/Studio/Utils/StudioUtils.cpp11
2 files changed, 11 insertions, 3 deletions
diff --git a/src/Authoring/Studio/Application/StudioApp.cpp b/src/Authoring/Studio/Application/StudioApp.cpp
index 26c96f9c..9452183d 100644
--- a/src/Authoring/Studio/Application/StudioApp.cpp
+++ b/src/Authoring/Studio/Application/StudioApp.cpp
@@ -88,6 +88,9 @@ int main(int argc, char *argv[])
#endif
SharedTools::QtSingleApplication guiApp(QStringLiteral("Qt3DStudio"), argc, argv);
+ // Fix for uia and uip file attribute random ordering (see QTBUG-8158)
+ qSetGlobalQHashSeed(1720419);
+
#if defined(Q_OS_MACOS)
QSurfaceFormat openGL33Format;
openGL33Format.setRenderableType(QSurfaceFormat::OpenGL);
diff --git a/src/Authoring/Studio/Utils/StudioUtils.cpp b/src/Authoring/Studio/Utils/StudioUtils.cpp
index ba6b872f..16ca1253 100644
--- a/src/Authoring/Studio/Utils/StudioUtils.cpp
+++ b/src/Authoring/Studio/Utils/StudioUtils.cpp
@@ -86,7 +86,8 @@ qreal StudioUtils::devicePixelRatio(QWindow *window)
bool StudioUtils::readFileToDomDocument(const QString &filePath, QDomDocument &domDoc)
{
QFile file(filePath);
- if (!file.open(QFile::Text | QIODevice::ReadOnly)) {
+ if (!file.open(QIODevice::ReadOnly)) {
+ file.setTextModeEnabled(false);
qWarning() << __FUNCTION__ << file.errorString() << "'" << filePath << "'";
return false;
}
@@ -99,7 +100,8 @@ bool StudioUtils::openDomDocumentSave(QSaveFile &file, QDomDocument &domDoc)
{
if (!readFileToDomDocument(file.fileName(), domDoc))
return false;
- if (!file.open(QFile::Text | QIODevice::WriteOnly)) {
+ if (!file.open(QIODevice::WriteOnly)) {
+ file.setTextModeEnabled(false);
qWarning() << __FUNCTION__ << file.errorString();
return false;
}
@@ -109,6 +111,8 @@ bool StudioUtils::openDomDocumentSave(QSaveFile &file, QDomDocument &domDoc)
// Saves contents of a QDomDocument into a previously opened text file
bool StudioUtils::commitDomDocumentSave(QSaveFile &file, const QDomDocument &domDoc)
{
+ // Disable end-of-line conversions
+ file.setTextModeEnabled(false);
// Overwrites entire file
if (file.resize(0) && file.write(domDoc.toByteArray(4)) != -1 && file.commit())
return true;
@@ -120,7 +124,8 @@ bool StudioUtils::commitDomDocumentSave(QSaveFile &file, const QDomDocument &dom
// Opens text file for saving without reading its contents
bool StudioUtils::openTextSave(QSaveFile &file)
{
- if (!file.open(QFile::Text | QIODevice::WriteOnly)) {
+ if (!file.open(QIODevice::WriteOnly)) {
+ file.setTextModeEnabled(false);
qWarning() << __FUNCTION__ << file.errorString();
return false;
}