QFont: Don't detach unless value has really changed

Change-Id: I496b0102853d04652322bf8751e5824aaa0725b7
Reviewed-by: Eskil Abrahamsen Blomfeldt <eskil.abrahamsen-blomfeldt@digia.com>
Reviewed-by: Lars Knoll <lars.knoll@digia.com>
This commit is contained in:
Konstantin Ritt 2012-10-11 19:47:58 +03:00 committed by The Qt Project
parent c967c9ec7f
commit 34823524ae

View File

@ -760,6 +760,9 @@ QString QFont::family() const
*/
void QFont::setFamily(const QString &family)
{
if ((resolve_mask & QFont::FamilyResolved) && d->request.family == family)
return;
detach();
d->request.family = family;
@ -793,6 +796,9 @@ QString QFont::styleName() const
*/
void QFont::setStyleName(const QString &styleName)
{
if ((resolve_mask & QFont::StyleNameResolved) && d->request.styleName == styleName)
return;
detach();
d->request.styleName = styleName;
@ -892,6 +898,9 @@ int QFont::pointSize() const
*/
void QFont::setHintingPreference(HintingPreference hintingPreference)
{
if ((resolve_mask & QFont::HintingPreferenceResolved) && d->request.hintingPreference == hintingPreference)
return;
detach();
d->request.hintingPreference = hintingPreference;
@ -922,6 +931,9 @@ void QFont::setPointSize(int pointSize)
return;
}
if ((resolve_mask & QFont::SizeResolved) && d->request.pointSize == qreal(pointSize))
return;
detach();
d->request.pointSize = qreal(pointSize);
@ -944,6 +956,9 @@ void QFont::setPointSizeF(qreal pointSize)
return;
}
if ((resolve_mask & QFont::SizeResolved) && d->request.pointSize == pointSize)
return;
detach();
d->request.pointSize = pointSize;
@ -979,6 +994,9 @@ void QFont::setPixelSize(int pixelSize)
return;
}
if ((resolve_mask & QFont::SizeResolved) && d->request.pixelSize == qreal(pixelSize))
return;
detach();
d->request.pixelSize = pixelSize;
@ -1034,6 +1052,9 @@ QFont::Style QFont::style() const
*/
void QFont::setStyle(Style style)
{
if ((resolve_mask & QFont::StyleResolved) && d->request.style == style)
return;
detach();
d->request.style = style;
@ -1077,6 +1098,9 @@ void QFont::setWeight(int weight)
{
Q_ASSERT_X(weight >= 0 && weight <= 99, "QFont::setWeight", "Weight must be between 0 and 99");
if ((resolve_mask & QFont::WeightResolved) && d->request.weight == weight)
return;
detach();
d->request.weight = weight;
@ -1122,6 +1146,9 @@ bool QFont::underline() const
*/
void QFont::setUnderline(bool enable)
{
if ((resolve_mask & QFont::UnderlineResolved) && d->underline == enable)
return;
detach();
d->underline = enable;
@ -1145,6 +1172,9 @@ bool QFont::overline() const
*/
void QFont::setOverline(bool enable)
{
if ((resolve_mask & QFont::OverlineResolved) && d->overline == enable)
return;
detach();
d->overline = enable;
@ -1169,6 +1199,9 @@ bool QFont::strikeOut() const
*/
void QFont::setStrikeOut(bool enable)
{
if ((resolve_mask & QFont::StrikeOutResolved) && d->strikeOut == enable)
return;
detach();
d->strikeOut = enable;
@ -1193,6 +1226,9 @@ bool QFont::fixedPitch() const
*/
void QFont::setFixedPitch(bool enable)
{
if ((resolve_mask & QFont::FixedPitchResolved) && d->request.fixedPitch == enable)
return;
detach();
d->request.fixedPitch = enable;
@ -1223,7 +1259,11 @@ bool QFont::kerning() const
*/
void QFont::setKerning(bool enable)
{
if ((resolve_mask & QFont::KerningResolved) && d->kerning == enable)
return;
detach();
d->kerning = enable;
resolve_mask |= QFont::KerningResolved;
}
@ -1339,13 +1379,13 @@ QFont::StyleHint QFont::styleHint() const
*/
void QFont::setStyleHint(StyleHint hint, StyleStrategy strategy)
{
detach();
if ((resolve_mask & (QFont::StyleHintResolved | QFont::StyleStrategyResolved)) &&
(StyleHint) d->request.styleHint == hint &&
(StyleStrategy) d->request.styleStrategy == strategy)
return;
detach();
d->request.styleHint = hint;
d->request.styleStrategy = strategy;
resolve_mask |= QFont::StyleHintResolved;
@ -1360,12 +1400,12 @@ void QFont::setStyleHint(StyleHint hint, StyleStrategy strategy)
*/
void QFont::setStyleStrategy(StyleStrategy s)
{
detach();
if ((resolve_mask & QFont::StyleStrategyResolved) &&
s == (StyleStrategy)d->request.styleStrategy)
return;
detach();
d->request.styleStrategy = s;
resolve_mask |= QFont::StyleStrategyResolved;
}
@ -1593,10 +1633,10 @@ QFont::Capitalization QFont::capitalization() const
*/
void QFont::setRawMode(bool enable)
{
detach();
if ((bool) d->rawMode == enable) return;
detach();
d->rawMode = enable;
}