summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJanne Kangas <janne.kangas@qt.io>2019-10-28 12:14:26 +0200
committerJanne Kangas <janne.kangas@qt.io>2019-11-06 09:35:24 +0200
commit3e803a3ff7db5ccd5085533d094fbca3732b0f52 (patch)
tree780248b6ccdfabd6d882e34cdc8da33d8b0c4871
parent8803caed932cb4c5627310223a72a137ea5c99f3 (diff)
Store line feeds as substitute characters in UIP
To avoid using real line breaks in UIP file for string-typed values, replace \n sequence with a non-printable unicode char at file save. Revert this at file load. Change-Id: I215a88c4d85bc2c0c3b63f31d6cd1cfdf20b16ca Task-id: QT3DS-3993 Reviewed-by: Tomi Korpipää <tomi.korpipaa@qt.io> Reviewed-by: Miikka Heikkinen <miikka.heikkinen@qt.io>
-rw-r--r--src/dm/systems/Qt3DSDMWStrOps.h4
-rw-r--r--src/runtimerender/Qt3DSRenderUIPLoader.cpp4
2 files changed, 8 insertions, 0 deletions
diff --git a/src/dm/systems/Qt3DSDMWStrOps.h b/src/dm/systems/Qt3DSDMWStrOps.h
index b1e1fb0..71e952b 100644
--- a/src/dm/systems/Qt3DSDMWStrOps.h
+++ b/src/dm/systems/Qt3DSDMWStrOps.h
@@ -29,6 +29,10 @@
#pragma once
#ifndef QT3DSDM_WSTR_OPS_H
#define QT3DSDM_WSTR_OPS_H
+
+// Unicode substitute char to replace linefeed in user-inputted strings in UIP
+#define LINE_BREAK_SUBSTITUTE "\uE000"
+
namespace qt3dsdm {
// Template base class so that we can convert items to and from wide string
template <typename TDataType>
diff --git a/src/runtimerender/Qt3DSRenderUIPLoader.cpp b/src/runtimerender/Qt3DSRenderUIPLoader.cpp
index 073df7f..24e4c18 100644
--- a/src/runtimerender/Qt3DSRenderUIPLoader.cpp
+++ b/src/runtimerender/Qt3DSRenderUIPLoader.cpp
@@ -960,6 +960,10 @@ struct SRenderUIPLoader : public IDOMReferenceResolver
{
ParseProperties(static_cast<SNode &>(inItem), inParser);
ITERATE_QT3DS_RENDER_TEXT_PROPERTIES
+ // QT3DS-3993: store line feeds as replacement chars in UIP
+ auto text = QString::fromUtf8(inItem.m_Text);
+ text.replace(LINE_BREAK_SUBSTITUTE, "\n");
+ inItem.m_Text = m_StrTable.RegisterStr(text);
}
void ParseProperties(SLightmaps &inItem, IPropertyParser &inParser)
{