diff --git a/src/core/qgsxmlutils.cpp b/src/core/qgsxmlutils.cpp index db5f1f1a897..a2bed40ef6d 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() );