Fix constness of QPaintDevice arguments
QFont, QFontMetrics, QFontMetricsF and QTextLayout constructors use only const methods of QPaintDevice so there is no reason for them to require a non-const pointer argument Fixes: QTBUG-65967 Change-Id: Ibfcdef2a25f0cd4284dad76135fc4c9bf5667d7a Reviewed-by: Samuel Gaist <samuel.gaist@idiap.ch> Reviewed-by: Christian Ehrlicher <ch.ehrlicher@gmx.de> Reviewed-by: Eskil Abrahamsen Blomfeldt <eskil.abrahamsen-blomfeldt@qt.io>
This commit is contained in:
parent
85b4aaaa99
commit
c0c4be672b
@ -562,14 +562,25 @@ QFontEngineData::~QFontEngineData()
|
|||||||
\since 5.2
|
\since 5.2
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0)
|
||||||
/*!
|
/*!
|
||||||
|
\obsolete
|
||||||
Constructs a font from \a font for use on the paint device \a pd.
|
Constructs a font from \a font for use on the paint device \a pd.
|
||||||
*/
|
*/
|
||||||
QFont::QFont(const QFont &font, QPaintDevice *pd)
|
QFont::QFont(const QFont &font, QPaintDevice *pd)
|
||||||
|
: QFont(font, static_cast<const QPaintDevice*>(pd))
|
||||||
|
{}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/*!
|
||||||
|
\since 5.13
|
||||||
|
Constructs a font from \a font for use on the paint device \a pd.
|
||||||
|
*/
|
||||||
|
QFont::QFont(const QFont &font, const QPaintDevice *pd)
|
||||||
: resolve_mask(font.resolve_mask)
|
: resolve_mask(font.resolve_mask)
|
||||||
{
|
{
|
||||||
Q_ASSERT(pd != 0);
|
Q_ASSERT(pd);
|
||||||
int dpi = pd->logicalDpiY();
|
const int dpi = pd->logicalDpiY();
|
||||||
const int screen = 0;
|
const int screen = 0;
|
||||||
if (font.d->dpi != dpi || font.d->screen != screen ) {
|
if (font.d->dpi != dpi || font.d->screen != screen ) {
|
||||||
d = new QFontPrivate(*font.d);
|
d = new QFontPrivate(*font.d);
|
||||||
|
@ -170,8 +170,11 @@ public:
|
|||||||
|
|
||||||
QFont();
|
QFont();
|
||||||
QFont(const QString &family, int pointSize = -1, int weight = -1, bool italic = false);
|
QFont(const QString &family, int pointSize = -1, int weight = -1, bool italic = false);
|
||||||
QFont(const QFont &, QPaintDevice *pd);
|
#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0)
|
||||||
QFont(const QFont &);
|
QFont(const QFont &font, QPaintDevice *pd);
|
||||||
|
#endif
|
||||||
|
QFont(const QFont &font, const QPaintDevice *pd);
|
||||||
|
QFont(const QFont &font);
|
||||||
~QFont();
|
~QFont();
|
||||||
|
|
||||||
void swap(QFont &other)
|
void swap(QFont &other)
|
||||||
|
@ -156,6 +156,8 @@ QFontMetrics::QFontMetrics(const QFont &font)
|
|||||||
}
|
}
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
|
\since 5.13
|
||||||
|
\fn QFontMetrics::QFontMetrics(const QFont &font, const QPaintDevice *paintdevice)
|
||||||
Constructs a font metrics object for \a font and \a paintdevice.
|
Constructs a font metrics object for \a font and \a paintdevice.
|
||||||
|
|
||||||
The font metrics will be compatible with the paintdevice passed.
|
The font metrics will be compatible with the paintdevice passed.
|
||||||
@ -168,9 +170,21 @@ QFontMetrics::QFontMetrics(const QFont &font)
|
|||||||
passed in the constructor at the time it is created, and is not
|
passed in the constructor at the time it is created, and is not
|
||||||
updated if the font's attributes are changed later.
|
updated if the font's attributes are changed later.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0)
|
||||||
|
/*!
|
||||||
|
\fn QFontMetrics::QFontMetrics(const QFont &font, QPaintDevice *paintdevice)
|
||||||
|
\obsolete
|
||||||
|
Identical to QFontMetrics::QFontMetrics(const QFont &font, const QPaintDevice *paintdevice)
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
QFontMetrics::QFontMetrics(const QFont &font, QPaintDevice *paintdevice)
|
QFontMetrics::QFontMetrics(const QFont &font, QPaintDevice *paintdevice)
|
||||||
|
#else
|
||||||
|
QFontMetrics::QFontMetrics(const QFont &font, const QPaintDevice *paintdevice)
|
||||||
|
#endif
|
||||||
{
|
{
|
||||||
int dpi = paintdevice ? paintdevice->logicalDpiY() : qt_defaultDpi();
|
const int dpi = paintdevice ? paintdevice->logicalDpiY() : qt_defaultDpi();
|
||||||
const int screen = 0;
|
const int screen = 0;
|
||||||
if (font.d->dpi != dpi || font.d->screen != screen ) {
|
if (font.d->dpi != dpi || font.d->screen != screen ) {
|
||||||
d = new QFontPrivate(*font.d);
|
d = new QFontPrivate(*font.d);
|
||||||
@ -1127,6 +1141,8 @@ QFontMetricsF::QFontMetricsF(const QFont &font)
|
|||||||
}
|
}
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
|
\fn QFontMetricsF::QFontMetricsF(const QFont &font, const QPaintDevice *paintdevice)
|
||||||
|
\since 5.13
|
||||||
Constructs a font metrics object for \a font and \a paintdevice.
|
Constructs a font metrics object for \a font and \a paintdevice.
|
||||||
|
|
||||||
The font metrics will be compatible with the paintdevice passed.
|
The font metrics will be compatible with the paintdevice passed.
|
||||||
@ -1139,7 +1155,20 @@ QFontMetricsF::QFontMetricsF(const QFont &font)
|
|||||||
passed in the constructor at the time it is created, and is not
|
passed in the constructor at the time it is created, and is not
|
||||||
updated if the font's attributes are changed later.
|
updated if the font's attributes are changed later.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0)
|
||||||
|
/*!
|
||||||
|
\fn QFontMetricsF::QFontMetricsF(const QFont &font, QPaintDevice *paintdevice)
|
||||||
|
\obsolete
|
||||||
|
Identical to QFontMetricsF::QFontMetricsF(const QFont &font, const QPaintDevice *paintdevice)
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
QFontMetricsF::QFontMetricsF(const QFont &font, QPaintDevice *paintdevice)
|
QFontMetricsF::QFontMetricsF(const QFont &font, QPaintDevice *paintdevice)
|
||||||
|
#else
|
||||||
|
QFontMetricsF::QFontMetricsF(const QFont &font, const QPaintDevice *paintdevice)
|
||||||
|
#endif
|
||||||
{
|
{
|
||||||
int dpi = paintdevice ? paintdevice->logicalDpiY() : qt_defaultDpi();
|
int dpi = paintdevice ? paintdevice->logicalDpiY() : qt_defaultDpi();
|
||||||
const int screen = 0;
|
const int screen = 0;
|
||||||
|
@ -59,7 +59,19 @@ class Q_GUI_EXPORT QFontMetrics
|
|||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
explicit QFontMetrics(const QFont &);
|
explicit QFontMetrics(const QFont &);
|
||||||
QFontMetrics(const QFont &, QPaintDevice *pd);
|
#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0)
|
||||||
|
QFontMetrics(const QFont &font, QPaintDevice *pd);
|
||||||
|
#ifndef Q_QDOC
|
||||||
|
// the template is necessary to make QFontMetrics(font,nullptr) and QFontMetrics(font,NULL)
|
||||||
|
// not ambiguous. Implementation detail that should not be documented.
|
||||||
|
template<char = 0>
|
||||||
|
#endif
|
||||||
|
QFontMetrics(const QFont &font, const QPaintDevice *pd)
|
||||||
|
: QFontMetrics(font, const_cast<QPaintDevice*>(pd))
|
||||||
|
{}
|
||||||
|
#else
|
||||||
|
QFontMetrics(const QFont &font, const QPaintDevice *pd);
|
||||||
|
#endif
|
||||||
QFontMetrics(const QFontMetrics &);
|
QFontMetrics(const QFontMetrics &);
|
||||||
~QFontMetrics();
|
~QFontMetrics();
|
||||||
|
|
||||||
@ -137,8 +149,20 @@ Q_DECLARE_SHARED(QFontMetrics)
|
|||||||
class Q_GUI_EXPORT QFontMetricsF
|
class Q_GUI_EXPORT QFontMetricsF
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
explicit QFontMetricsF(const QFont &);
|
explicit QFontMetricsF(const QFont &font);
|
||||||
QFontMetricsF(const QFont &, QPaintDevice *pd);
|
#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0)
|
||||||
|
QFontMetricsF(const QFont &font, QPaintDevice *pd);
|
||||||
|
#ifndef Q_QDOC
|
||||||
|
// the template is necessary to make QFontMetrics(font,nullptr) and QFontMetrics(font,NULL)
|
||||||
|
// not ambiguous. Implementation detail that should not be documented.
|
||||||
|
template<char = 0>
|
||||||
|
#endif
|
||||||
|
QFontMetricsF(const QFont &font, const QPaintDevice *pd)
|
||||||
|
: QFontMetricsF(font, const_cast<QPaintDevice*>(pd))
|
||||||
|
{}
|
||||||
|
#else
|
||||||
|
QFontMetricsF(const QFont &font, const QPaintDevice *pd);
|
||||||
|
#endif
|
||||||
QFontMetricsF(const QFontMetrics &);
|
QFontMetricsF(const QFontMetrics &);
|
||||||
QFontMetricsF(const QFontMetricsF &);
|
QFontMetricsF(const QFontMetricsF &);
|
||||||
~QFontMetricsF();
|
~QFontMetricsF();
|
||||||
|
@ -344,6 +344,8 @@ QTextLayout::QTextLayout(const QString& text)
|
|||||||
}
|
}
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
|
\since 5.13
|
||||||
|
\fn QTextLayout::QTextLayout(const QString &text, const QFont &font, const QPaintDevice *paintdevice)
|
||||||
Constructs a text layout to lay out the given \a text with the specified
|
Constructs a text layout to lay out the given \a text with the specified
|
||||||
\a font.
|
\a font.
|
||||||
|
|
||||||
@ -351,11 +353,20 @@ QTextLayout::QTextLayout(const QString& text)
|
|||||||
the paint device, \a paintdevice. If \a paintdevice is 0 the
|
the paint device, \a paintdevice. If \a paintdevice is 0 the
|
||||||
calculations will be done in screen metrics.
|
calculations will be done in screen metrics.
|
||||||
*/
|
*/
|
||||||
QTextLayout::QTextLayout(const QString& text, const QFont &font, QPaintDevice *paintdevice)
|
|
||||||
|
#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0)
|
||||||
|
/*!
|
||||||
|
\fn QTextLayout::QTextLayout(const QString &text, const QFont &font, QPaintDevice *paintdevice)
|
||||||
|
\obsolete
|
||||||
|
Identical to QTextLayout::QTextLayout(const QString &text, const QFont &font, const QPaintDevice *paintdevice)
|
||||||
|
*/
|
||||||
|
|
||||||
|
QTextLayout::QTextLayout(const QString &text, const QFont &font, QPaintDevice *paintdevice)
|
||||||
|
#else
|
||||||
|
QTextLayout::QTextLayout(const QString &text, const QFont &font, const QPaintDevice *paintdevice)
|
||||||
|
#endif
|
||||||
{
|
{
|
||||||
QFont f(font);
|
const QFont f(paintdevice ? QFont(font, paintdevice) : font);
|
||||||
if (paintdevice)
|
|
||||||
f = QFont(font, paintdevice);
|
|
||||||
d = new QTextEngine((text.isNull() ? (const QString&)QString::fromLatin1("") : text), f);
|
d = new QTextEngine((text.isNull() ? (const QString&)QString::fromLatin1("") : text), f);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -107,7 +107,19 @@ public:
|
|||||||
// does itemization
|
// does itemization
|
||||||
QTextLayout();
|
QTextLayout();
|
||||||
QTextLayout(const QString& text);
|
QTextLayout(const QString& text);
|
||||||
QTextLayout(const QString& text, const QFont &font, QPaintDevice *paintdevice = nullptr);
|
#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0)
|
||||||
|
QTextLayout(const QString &text, const QFont &font, QPaintDevice *paintdevice = nullptr);
|
||||||
|
#ifndef Q_QDOC
|
||||||
|
// the template is necessary to make QTextLayout(font,text,nullptr) and QTextLayout(font,text,NULL)
|
||||||
|
// not ambiguous. Implementation detail that should not be documented.
|
||||||
|
template<char = 0>
|
||||||
|
#endif
|
||||||
|
QTextLayout(const QString &text, const QFont &font, const QPaintDevice *paintdevice)
|
||||||
|
: QTextLayout(text, font, const_cast<QPaintDevice*>(paintdevice))
|
||||||
|
{}
|
||||||
|
#else
|
||||||
|
QTextLayout(const QString &text, const QFont &font, const QPaintDevice *paintdevice = nullptr);
|
||||||
|
#endif
|
||||||
QTextLayout(const QTextBlock &b);
|
QTextLayout(const QTextBlock &b);
|
||||||
~QTextLayout();
|
~QTextLayout();
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user