Refactor QXmlStreamWriterPrivate constructor to modernize initialization

Apply NSDMI and move initializations to the constructor initializer list

Fixes: QTBUG-135897
Pick-to: 6.8
Change-Id: I7adff41fa006669677df457704d20c02f1af7197
Reviewed-by: Ivan Solovev <ivan.solovev@qt.io>
(cherry picked from commit 3265f409394e821605cfd1888a26f7fbdd4ba682)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
This commit is contained in:
Magdalena Stojek 2025-04-11 10:14:49 +02:00 committed by Qt Cherry-pick Bot
parent 4a8350da23
commit f6591e6638

View File

@ -2938,8 +2938,8 @@ public:
bool finishStartElement(bool contents = true); bool finishStartElement(bool contents = true);
void writeStartElement(QAnyStringView namespaceUri, QAnyStringView name, void writeStartElement(QAnyStringView namespaceUri, QAnyStringView name,
StartElementOption option = StartElementOption::KeepEverything); StartElementOption option = StartElementOption::KeepEverything);
QIODevice *device; QIODevice *device = nullptr;
QString *stringDevice; QString *stringDevice = nullptr;
uint deleteDevice :1; uint deleteDevice :1;
uint inStartElement :1; uint inStartElement :1;
uint inEmptyElement :1; uint inEmptyElement :1;
@ -2950,15 +2950,15 @@ public:
uint autoFormatting :1; uint autoFormatting :1;
uint didWriteStartDocument :1; uint didWriteStartDocument :1;
uint didWriteAnyToken :1; uint didWriteAnyToken :1;
std::string autoFormattingIndent; std::string autoFormattingIndent = std::string(4, ' ');
NamespaceDeclaration emptyNamespace; NamespaceDeclaration emptyNamespace;
qsizetype lastNamespaceDeclaration; qsizetype lastNamespaceDeclaration = 1;
NamespaceDeclaration &addExtraNamespace(QAnyStringView namespaceUri, QAnyStringView prefix); NamespaceDeclaration &addExtraNamespace(QAnyStringView namespaceUri, QAnyStringView prefix);
NamespaceDeclaration &findNamespace(QAnyStringView namespaceUri, bool writeDeclaration = false, bool noDefault = false); NamespaceDeclaration &findNamespace(QAnyStringView namespaceUri, bool writeDeclaration = false, bool noDefault = false);
void writeNamespaceDeclaration(const NamespaceDeclaration &namespaceDeclaration); void writeNamespaceDeclaration(const NamespaceDeclaration &namespaceDeclaration);
int namespacePrefixCount; int namespacePrefixCount = 0;
void indent(int level); void indent(int level);
private: private:
@ -2969,22 +2969,12 @@ private:
QXmlStreamWriterPrivate::QXmlStreamWriterPrivate(QXmlStreamWriter *q) 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) void QXmlStreamWriterPrivate::write(QAnyStringView s)