Don't change resolve mask when setting brush doesn't change palette
After556511f9f3
, which moved the resolve mask storage into the palette's d-pointer, modifying the resolve mask requires a detach. As of now, we only detached when setting a different brush, but always modified the resolve mask, which broke palettes that shared the d-pointer (likely the global default palette). However, detaching has negative side effects when styles set brushes on temporary palette objects and then use that palette object's cache key to build a cache of pixmaps. As each drawing would detach the palette (even if the palette doesn't change, which is likely), the cache key changes with each detach, and the cache would quickly increase in size. This was addressed in changesd7bcdc3a44
and1e75dcf251
. We can either detach and find other ways to address the issues from QTBUG-65475, or we can not change the resolve mask when the brush doesn't change and completely ignore the call. Since QFont ignores the setting of any attribute to a value that is identical to the current value, and since it's possible to force that the resolve-bit is set by calling setBrush twice with different brushes, ignoring the call seems like the better solution. [ChangeLog][QtGui][QPalette] Setting a brush on a palette that is identical to the current brush no longer sets the resolve mask bit for that particular role, so items using the palette will continue to inherit changes from parent items. Fixes: QTBUG-98762 Task-number: QTBUG-65475 Pick-to: 6.2 Change-Id: Ife0f934b6a066858408ef75b7bb7ab61193ceb47 Reviewed-by: Simon Hausmann <hausmann@gmail.com> Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io> Reviewed-by: Lars Knoll <lars.knoll@qt.io>
This commit is contained in:
parent
98c2260c3b
commit
56bd1b76d2
@ -787,9 +787,8 @@ void QPalette::setBrush(ColorGroup cg, ColorRole cr, const QBrush &b)
|
||||
if (d->br[cg][cr] != b) {
|
||||
detach();
|
||||
d->br[cg][cr] = b;
|
||||
d->resolveMask |= ResolveMask(1) << bitPosition(cg, cr);
|
||||
}
|
||||
|
||||
d->resolveMask |= ResolveMask(1) << bitPosition(cg, cr);
|
||||
}
|
||||
|
||||
/*!
|
||||
|
@ -227,6 +227,14 @@ void tst_QPalette::isBrushSet()
|
||||
QVERIFY(p.isBrushSet(QPalette::Active, QPalette::LinkVisited));
|
||||
QVERIFY(p.isBrushSet(QPalette::Inactive, QPalette::LinkVisited));
|
||||
QVERIFY(p.isBrushSet(QPalette::Disabled, QPalette::LinkVisited));
|
||||
|
||||
// Don't set flag when brush doesn't change (and also don't detach - QTBUG-98762)
|
||||
QPalette p2;
|
||||
QPalette p3;
|
||||
QVERIFY(!p2.isBrushSet(QPalette::Active, QPalette::Dark));
|
||||
p2.setBrush(QPalette::Active, QPalette::Dark, p2.brush(QPalette::Active, QPalette::Dark));
|
||||
QVERIFY(!p3.isBrushSet(QPalette::Active, QPalette::Dark));
|
||||
QVERIFY(!p2.isBrushSet(QPalette::Active, QPalette::Dark));
|
||||
}
|
||||
|
||||
void tst_QPalette::setAllPossibleBrushes()
|
||||
|
Loading…
Reference in New Issue
Block a user