From 24f07e376955991f8da83d9e3b71bbfcede5acd9 Mon Sep 17 00:00:00 2001 From: Alessandro Pasotti Date: Mon, 3 Feb 2020 13:39:51 +0100 Subject: [PATCH] Do not insert 0x0 in XML Fixes #34218 --- src/core/qgsxmlutils.cpp | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/core/qgsxmlutils.cpp b/src/core/qgsxmlutils.cpp index db5f1f1a8974..a2bed40ef6d3 100644 --- a/src/core/qgsxmlutils.cpp +++ b/src/core/qgsxmlutils.cpp @@ -161,11 +161,15 @@ QDomElement QgsXmlUtils::writeVariant( const QVariant &value, QDomDocument &doc case QVariant::LongLong: case QVariant::ULongLong: case QVariant::String: - case QVariant::Char: element.setAttribute( QStringLiteral( "type" ), QVariant::typeToName( value.type() ) ); element.setAttribute( QStringLiteral( "value" ), value.toString() ); break; + case QVariant::Char: + element.setAttribute( QStringLiteral( "type" ), QVariant::typeToName( value.type() ) ); + element.setAttribute( QStringLiteral( "value" ), value.isNull() ? QString() : value.toString() ); + break; + case QVariant::Color: element.setAttribute( QStringLiteral( "type" ), QStringLiteral( "color" ) ); element.setAttribute( QStringLiteral( "value" ), value.value< QColor >().isValid() ? QgsSymbolLayerUtils::encodeColor( value.value< QColor >() ) : QString() );