QPalette: detach before modifying resolve mask when resolving

Amends 1d961491d8. We modify the resolve
mask after making a shared copy of 'other', so we must detach. Call the
setter designed for that purpose.

Pick-to: 6.4 6.3 6.2
Task-number: QTBUG-98762
Change-Id: I4f45223e74764a341378992172787fae73efb8b7
Reviewed-by: JiDe Zhang <zhangjide@uniontech.com>
Reviewed-by: Shawn Rutledge <shawn.rutledge@qt.io>
This commit is contained in:
Volker Hilsheimer 2022-07-15 08:50:37 +02:00
parent 2c81ba2df9
commit 37c829f511
2 changed files with 8 additions and 1 deletions

View File

@ -921,7 +921,7 @@ QPalette QPalette::resolve(const QPalette &other) const
if ((*this == other && d->resolveMask == other.d->resolveMask)
|| d->resolveMask == 0) {
QPalette o = other;
o.d->resolveMask = d->resolveMask;
o.setResolveMask(d->resolveMask);
return o;
}

View File

@ -102,9 +102,16 @@ void tst_QPalette::resolve()
// ensure the resolve mask is full
for (int r = 0; r < QPalette::NColorRoles; ++r)
p3.setBrush(QPalette::All, QPalette::ColorRole(r), Qt::red);
const QPalette::ResolveMask fullMask = p3.resolveMask();
QPalette p3ResolvedToP1 = p3.resolve(p1);
QVERIFY(p3ResolvedToP1.isCopyOf(p3));
QPalette p4;
QCOMPARE(p4.resolveMask(), QPalette::ResolveMask{});
// resolve must detach even if p4 has no mask
p4 = p4.resolve(p3);
QCOMPARE(p3.resolveMask(), fullMask);
}