Unwrap private QPalette data member

Following 556511f9f3, there is only one
data member in addition to the shared QPalettePrivate, so we don't need
a data struct anymore.

Change-Id: I8d7f33ed042e47464eb5f60a048956f8bf70e0b9
Reviewed-by: Lars Knoll <lars.knoll@qt.io>
bb10
Volker Hilsheimer 2020-10-13 21:27:58 +02:00
parent 63790184c7
commit 2cc8d801aa
2 changed files with 12 additions and 15 deletions

View File

@ -669,7 +669,7 @@ QPalette::QPalette(const QColor &button, const QColor &window)
This constructor is fast thanks to \l{implicit sharing}.
*/
QPalette::QPalette(const QPalette &p)
: d(p.d), data(p.data)
: d(p.d), currentGroup(p.currentGroup)
{
d->ref.ref();
}
@ -709,7 +709,7 @@ void QPalette::init()
QPalette &QPalette::operator=(const QPalette &p)
{
p.d->ref.ref();
data = p.data;
currentGroup = p.currentGroup;
if (d && !d->ref.deref())
delete d;
d = p.d;
@ -754,7 +754,7 @@ const QBrush &QPalette::brush(ColorGroup gr, ColorRole cr) const
Q_ASSERT(cr < NColorRoles);
if(gr >= (int)NColorGroups) {
if(gr == Current) {
gr = data.currentGroup;
gr = currentGroup;
} else {
qWarning("QPalette::brush: Unknown ColorGroup: %d", (int)gr);
gr = Active;
@ -792,7 +792,7 @@ void QPalette::setBrush(ColorGroup cg, ColorRole cr, const QBrush &b)
}
if (cg == Current) {
cg = data.currentGroup;
cg = currentGroup;
} else if (cg >= NColorGroups) {
qWarning("QPalette::setBrush: Unknown ColorGroup: %d", cg);
cg = Active;
@ -823,7 +823,7 @@ void QPalette::setBrush(ColorGroup cg, ColorRole cr, const QBrush &b)
bool QPalette::isBrushSet(ColorGroup cg, ColorRole cr) const
{
if (cg == Current)
cg = data.currentGroup;
cg = currentGroup;
if (cg >= NColorGroups) {
qWarning() << "Wrong color group:" << cg;
@ -901,7 +901,7 @@ bool QPalette::isEqual(QPalette::ColorGroup group1, QPalette::ColorGroup group2)
{
if(group1 >= (int)NColorGroups) {
if(group1 == Current) {
group1 = data.currentGroup;
group1 = currentGroup;
} else {
qWarning("QPalette::brush: Unknown ColorGroup(1): %d", (int)group1);
group1 = Active;
@ -909,7 +909,7 @@ bool QPalette::isEqual(QPalette::ColorGroup group1, QPalette::ColorGroup group2)
}
if(group2 >= (int)NColorGroups) {
if(group2 == Current) {
group2 = data.currentGroup;
group2 = currentGroup;
} else {
qWarning("QPalette::brush: Unknown ColorGroup(2): %d", (int)group2);
group2 = Active;

View File

@ -68,13 +68,13 @@ public:
~QPalette();
QPalette &operator=(const QPalette &palette);
QPalette(QPalette &&other) noexcept
: d(qExchange(other.d, nullptr)), data(other.data)
: d(qExchange(other.d, nullptr)), currentGroup(other.currentGroup)
{}
QT_MOVE_ASSIGNMENT_OPERATOR_IMPL_VIA_PURE_SWAP(QPalette)
void swap(QPalette &other) noexcept
{
qSwap(data, other.data);
qSwap(currentGroup, other.currentGroup);
qSwap(d, other.d);
}
@ -95,8 +95,8 @@ public:
};
Q_ENUM(ColorRole)
inline ColorGroup currentColorGroup() const { return data.currentGroup; }
inline void setCurrentColorGroup(ColorGroup cg) { data.currentGroup = cg; }
inline ColorGroup currentColorGroup() const { return currentGroup; }
inline void setCurrentColorGroup(ColorGroup cg) { currentGroup = cg; }
inline const QColor &color(ColorGroup cg, ColorRole cr) const
{ return brush(cg, cr).color(); }
@ -169,10 +169,7 @@ private:
void detach();
QPalettePrivate *d;
struct Data {
ColorGroup currentGroup{Active};
};
Data data;
ColorGroup currentGroup{Active};
friend Q_GUI_EXPORT QDataStream &operator<<(QDataStream &s, const QPalette &p);
};