QFont*: fix some const-incorrectnesses involving QFontPrivate

Detected with a modified (deep const propagating) shared data pointer.

Most are fixed by using copy constructor and assignment operator
of the shared pointer instead of feeding it .data(). The rest
required adding const locally.

Change-Id: I51e36b9e7040dc2211ef4c5dadfbda73ad22c414
Reviewed-by: Konstantin Ritt <ritt.ks@gmail.com>
Reviewed-by: Olivier Goffart (Woboq GmbH) <ogoffart@woboq.com>
This commit is contained in:
Marc Mutz 2015-06-25 12:27:13 +02:00 committed by Konstantin Ritt
parent 69817f6ad1
commit bfdcbe8bfb
3 changed files with 19 additions and 19 deletions

View File

@ -549,7 +549,7 @@ QFont::QFont(const QFont &font, QPaintDevice *pd)
d->dpi = dpi;
d->screen = screen;
} else {
d = font.d.data();
d = font.d;
}
}
@ -654,7 +654,7 @@ QFont::QFont(const QString &family, int pointSize, int weight, bool italic)
Constructs a font that is a copy of \a font.
*/
QFont::QFont(const QFont &font)
: d(font.d.data()), resolve_mask(font.resolve_mask)
: d(font.d), resolve_mask(font.resolve_mask)
{
}
@ -670,7 +670,7 @@ QFont::~QFont()
*/
QFont &QFont::operator=(const QFont &font)
{
d = font.d.data();
d = font.d;
resolve_mask = font.resolve_mask;
return *this;
}
@ -1647,8 +1647,8 @@ bool QFont::operator<(const QFont &f) const
{
if (f.d == d) return false;
// the < operator for fontdefs ignores point sizes.
QFontDef &r1 = f.d->request;
QFontDef &r2 = d->request;
const QFontDef &r1 = f.d->request;
const QFontDef &r2 = d->request;
if (r1.pointSize != r2.pointSize) return r1.pointSize < r2.pointSize;
if (r1.pixelSize != r2.pixelSize) return r1.pixelSize < r2.pixelSize;
if (r1.weight != r2.weight) return r1.weight < r2.weight;
@ -2386,7 +2386,7 @@ QDataStream &operator>>(QDataStream &s, QFont &font)
that is not screen-compatible.
*/
QFontInfo::QFontInfo(const QFont &font)
: d(font.d.data())
: d(font.d)
{
}
@ -2394,7 +2394,7 @@ QFontInfo::QFontInfo(const QFont &font)
Constructs a copy of \a fi.
*/
QFontInfo::QFontInfo(const QFontInfo &fi)
: d(fi.d.data())
: d(fi.d)
{
}
@ -2410,7 +2410,7 @@ QFontInfo::~QFontInfo()
*/
QFontInfo &QFontInfo::operator=(const QFontInfo &fi)
{
d = fi.d.data();
d = fi.d;
return *this;
}

View File

@ -145,7 +145,7 @@ extern void qt_format_text(const QFont& font, const QRectF &_r,
metrics that are compatible with a certain paint device.
*/
QFontMetrics::QFontMetrics(const QFont &font)
: d(font.d.data())
: d(font.d)
{
}
@ -171,7 +171,7 @@ QFontMetrics::QFontMetrics(const QFont &font, QPaintDevice *paintdevice)
d->dpi = dpi;
d->screen = screen;
} else {
d = font.d.data();
d = font.d;
}
}
@ -180,7 +180,7 @@ QFontMetrics::QFontMetrics(const QFont &font, QPaintDevice *paintdevice)
Constructs a copy of \a fm.
*/
QFontMetrics::QFontMetrics(const QFontMetrics &fm)
: d(fm.d.data())
: d(fm.d)
{
}
@ -197,7 +197,7 @@ QFontMetrics::~QFontMetrics()
*/
QFontMetrics &QFontMetrics::operator=(const QFontMetrics &fm)
{
d = fm.d.data();
d = fm.d;
return *this;
}
@ -995,7 +995,7 @@ int QFontMetrics::lineWidth() const
from the given \a fontMetrics object.
*/
QFontMetricsF::QFontMetricsF(const QFontMetrics &fontMetrics)
: d(fontMetrics.d.data())
: d(fontMetrics.d)
{
}
@ -1006,7 +1006,7 @@ QFontMetricsF::QFontMetricsF(const QFontMetrics &fontMetrics)
*/
QFontMetricsF &QFontMetricsF::operator=(const QFontMetrics &other)
{
d = other.d.data();
d = other.d;
return *this;
}
@ -1034,7 +1034,7 @@ QFontMetricsF &QFontMetricsF::operator=(const QFontMetrics &other)
metrics that are compatible with a certain paint device.
*/
QFontMetricsF::QFontMetricsF(const QFont &font)
: d(font.d.data())
: d(font.d)
{
}
@ -1060,7 +1060,7 @@ QFontMetricsF::QFontMetricsF(const QFont &font, QPaintDevice *paintdevice)
d->dpi = dpi;
d->screen = screen;
} else {
d = font.d.data();
d = font.d;
}
}
@ -1069,7 +1069,7 @@ QFontMetricsF::QFontMetricsF(const QFont &font, QPaintDevice *paintdevice)
Constructs a copy of \a fm.
*/
QFontMetricsF::QFontMetricsF(const QFontMetricsF &fm)
: d(fm.d.data())
: d(fm.d)
{
}
@ -1086,7 +1086,7 @@ QFontMetricsF::~QFontMetricsF()
*/
QFontMetricsF &QFontMetricsF::operator=(const QFontMetricsF &fm)
{
d = fm.d.data();
d = fm.d;
return *this;
}

View File

@ -688,7 +688,7 @@ extern int qt_script_for_writing_system(QFontDatabase::WritingSystem writingSyst
QRawFont QRawFont::fromFont(const QFont &font, QFontDatabase::WritingSystem writingSystem)
{
QRawFont rawFont;
QFontPrivate *font_d = QFontPrivate::get(font);
const QFontPrivate *font_d = QFontPrivate::get(font);
int script = qt_script_for_writing_system(writingSystem);
QFontEngine *fe = font_d->engineForScript(script);