From 3e803a3ff7db5ccd5085533d094fbca3732b0f52 Mon Sep 17 00:00:00 2001 From: Janne Kangas Date: Mon, 28 Oct 2019 12:14:26 +0200 Subject: Store line feeds as substitute characters in UIP MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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ää Reviewed-by: Miikka Heikkinen --- src/dm/systems/Qt3DSDMWStrOps.h | 4 ++++ src/runtimerender/Qt3DSRenderUIPLoader.cpp | 4 ++++ 2 files changed, 8 insertions(+) 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 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(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) { -- cgit v1.2.3