From 5e9a1798cc697136aae4125a157e654d7e49530a Mon Sep 17 00:00:00 2001 From: Jere Tuliniemi Date: Thu, 10 Jan 2019 15:58:37 +0200 Subject: Support custom materials created from a QByteArray MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Allow a QByteArray to be used to create a custom material instead reading it from a file. Task-number: QT3DS-2906 Change-Id: I2718240186b62c0ff2bf36e5313bed6754472066 Reviewed-by: Miikka Heikkinen Reviewed-by: Tomi Korpipää Reviewed-by: Antti Määttä --- src/runtime/q3dscustommaterial.cpp | 14 ++++++++++++++ 1 file changed, 14 insertions(+) (limited to 'src/runtime/q3dscustommaterial.cpp') diff --git a/src/runtime/q3dscustommaterial.cpp b/src/runtime/q3dscustommaterial.cpp index 77b8cb3..592c19f 100644 --- a/src/runtime/q3dscustommaterial.cpp +++ b/src/runtime/q3dscustommaterial.cpp @@ -176,7 +176,21 @@ Q3DSCustomMaterial Q3DSCustomMaterialParser::parse(const QString &filename, bool *ok = false; return Q3DSCustomMaterial(); } + return parse(ok); +} +Q3DSCustomMaterial Q3DSCustomMaterialParser::parse(const QByteArray &data, bool *ok) +{ + if (!setSourceData(data)) { + if (ok != nullptr) + *ok = false; + return Q3DSCustomMaterial(); + } + return parse(ok); +} + +Q3DSCustomMaterial Q3DSCustomMaterialParser::parse(bool *ok) +{ m_material = Q3DSCustomMaterial(); QXmlStreamReader *r = reader(); -- cgit v1.2.3