From ada6e4fbe9f363a33d4f9341bbc468d22c0c1442 Mon Sep 17 00:00:00 2001 From: Allan Sandfeld Jensen Date: Thu, 15 Oct 2020 13:23:02 +0200 Subject: Fix some bad uses of QSharedPointerData::operator T* Avoid detaching where possible Change-Id: I438d3e66689aeef05951af86a48af2a6910da7c2 Reviewed-by: Thiago Macieira Reviewed-by: Giuseppe D'Angelo --- src/gui/text/qtextformat.cpp | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) (limited to 'src/gui') diff --git a/src/gui/text/qtextformat.cpp b/src/gui/text/qtextformat.cpp index af1fdfa653..850b4ad43d 100644 --- a/src/gui/text/qtextformat.cpp +++ b/src/gui/text/qtextformat.cpp @@ -919,13 +919,13 @@ void QTextFormat::merge(const QTextFormat &other) if (!other.d) return; - QTextFormatPrivate *d = this->d; + QTextFormatPrivate *p = d.data(); - const QList &otherProps = other.d->props; - d->props.reserve(d->props.size() + otherProps.size()); + const QList &otherProps = other.d.constData()->props; + p->props.reserve(p->props.size() + otherProps.size()); for (int i = 0; i < otherProps.count(); ++i) { - const QT_PREPEND_NAMESPACE(Property) &p = otherProps.at(i); - d->insertProperty(p.key, p.value); + const QT_PREPEND_NAMESPACE(Property) &prop = otherProps.at(i); + p->insertProperty(prop.key, prop.value); } } @@ -1261,10 +1261,10 @@ int QTextFormat::objectIndex() const void QTextFormat::setObjectIndex(int o) { if (o == -1) { - if (d) + if (d.constData()) d->clearProperty(ObjectIndex); } else { - if (!d) + if (!d.constData()) d = new QTextFormatPrivate; // ### type d->insertProperty(ObjectIndex, o); -- cgit v1.2.3