diff options
| author | Magdalena Stojek <magdalena.stojek@qt.io> | 2025-04-11 10:14:49 +0200 |
|---|---|---|
| committer | Magdalena Stojek <magdalena.stojek@qt.io> | 2025-04-14 14:05:10 +0200 |
| commit | 3265f409394e821605cfd1888a26f7fbdd4ba682 (patch) | |
| tree | 0134c29ea182839c5b70cedf546b62c46ea74cad /src/corelib/serialization/qxmlstream.cpp | |
| parent | 920a490d659836785f03d51edc11da1711ade965 (diff) | |
Refactor QXmlStreamWriterPrivate constructor to modernize initialization
Apply NSDMI and move initializations to the constructor initializer list
Fixes: QTBUG-135897
Pick-to: 6.9 6.8
Change-Id: I7adff41fa006669677df457704d20c02f1af7197
Reviewed-by: Ivan Solovev <ivan.solovev@qt.io>
Diffstat (limited to 'src/corelib/serialization/qxmlstream.cpp')
| -rw-r--r-- | src/corelib/serialization/qxmlstream.cpp | 30 |
1 files changed, 10 insertions, 20 deletions
diff --git a/src/corelib/serialization/qxmlstream.cpp b/src/corelib/serialization/qxmlstream.cpp index a01e98469de..7e14b098de9 100644 --- a/src/corelib/serialization/qxmlstream.cpp +++ b/src/corelib/serialization/qxmlstream.cpp @@ -2938,8 +2938,8 @@ public: bool finishStartElement(bool contents = true); void writeStartElement(QAnyStringView namespaceUri, QAnyStringView name, StartElementOption option = StartElementOption::KeepEverything); - QIODevice *device; - QString *stringDevice; + QIODevice *device = nullptr; + QString *stringDevice = nullptr; uint deleteDevice :1; uint inStartElement :1; uint inEmptyElement :1; @@ -2950,15 +2950,15 @@ public: uint autoFormatting :1; uint didWriteStartDocument :1; uint didWriteAnyToken :1; - std::string autoFormattingIndent; + std::string autoFormattingIndent = std::string(4, ' '); NamespaceDeclaration emptyNamespace; - qsizetype lastNamespaceDeclaration; + qsizetype lastNamespaceDeclaration = 1; NamespaceDeclaration &addExtraNamespace(QAnyStringView namespaceUri, QAnyStringView prefix); NamespaceDeclaration &findNamespace(QAnyStringView namespaceUri, bool writeDeclaration = false, bool noDefault = false); void writeNamespaceDeclaration(const NamespaceDeclaration &namespaceDeclaration); - int namespacePrefixCount; + int namespacePrefixCount = 0; void indent(int level); private: @@ -2969,22 +2969,12 @@ private: QXmlStreamWriterPrivate::QXmlStreamWriterPrivate(QXmlStreamWriter *q) - : autoFormattingIndent(4, ' ') + : q_ptr(q), deleteDevice(false), inStartElement(false), + inEmptyElement(false), lastWasStartElement(false), + wroteSomething(false), hasIoError(false), + hasEncodingError(false), autoFormatting(false), + didWriteStartDocument(false), didWriteAnyToken(false) { - q_ptr = q; - device = nullptr; - stringDevice = nullptr; - deleteDevice = false; - inStartElement = inEmptyElement = false; - wroteSomething = false; - hasIoError = false; - hasEncodingError = false; - lastWasStartElement = false; - lastNamespaceDeclaration = 1; - autoFormatting = false; - namespacePrefixCount = 0; - didWriteStartDocument = false; - didWriteAnyToken = false; } void QXmlStreamWriterPrivate::write(QAnyStringView s) |
