gui: use const methods more
to avoid implicit detach Change-Id: I2c7ae56e0866941e0f0b040129bfc40a9a961f3c Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
This commit is contained in:
parent
2c1fdad76c
commit
14505ca278
@ -829,7 +829,7 @@ QWindow *QGuiApplication::modalWindow()
|
||||
CHECK_QAPP_INSTANCE(nullptr)
|
||||
if (QGuiApplicationPrivate::self->modalWindowList.isEmpty())
|
||||
return nullptr;
|
||||
return QGuiApplicationPrivate::self->modalWindowList.first();
|
||||
return QGuiApplicationPrivate::self->modalWindowList.constFirst();
|
||||
}
|
||||
|
||||
static void updateBlockedStatusRecursion(QWindow *window, bool shouldBeBlocked)
|
||||
|
@ -784,8 +784,8 @@ QKeySequence::QKeySequence(StandardKey key)
|
||||
{
|
||||
const QList <QKeySequence> bindings = keyBindings(key);
|
||||
//pick only the first/primary shortcut from current bindings
|
||||
if (bindings.size() > 0) {
|
||||
d = bindings.first().d;
|
||||
if (!bindings.isEmpty()) {
|
||||
d = bindings.constFirst().d;
|
||||
d->ref.ref();
|
||||
}
|
||||
else
|
||||
|
@ -255,7 +255,7 @@ int QPageRanges::firstPage() const
|
||||
{
|
||||
if (isEmpty())
|
||||
return 0;
|
||||
return d->intervals.first().from;
|
||||
return d->intervals.constFirst().from;
|
||||
}
|
||||
|
||||
/*!
|
||||
@ -266,7 +266,7 @@ int QPageRanges::lastPage() const
|
||||
{
|
||||
if (isEmpty())
|
||||
return 0;
|
||||
return d->intervals.last().to;
|
||||
return d->intervals.constLast().to;
|
||||
}
|
||||
|
||||
/*!
|
||||
|
@ -1491,7 +1491,7 @@ QRectF QPainterPath::controlPointRect() const
|
||||
|
||||
bool QPainterPath::isEmpty() const
|
||||
{
|
||||
return !d_ptr || (d_ptr->elements.size() == 1 && d_ptr->elements.first().type == MoveToElement);
|
||||
return !d_ptr || (d_ptr->elements.size() == 1 && d_ptr->elements.constFirst().type == MoveToElement);
|
||||
}
|
||||
|
||||
/*!
|
||||
|
@ -777,7 +777,7 @@ size_t qHash(const QShader &s, size_t seed) noexcept
|
||||
seed = hash(seed, s.stage());
|
||||
if (!s.d->shaders.isEmpty()) {
|
||||
seed = hash(seed, s.d->shaders.firstKey());
|
||||
seed = hash(seed, s.d->shaders.first());
|
||||
seed = hash(seed, std::as_const(s.d->shaders).first());
|
||||
}
|
||||
}
|
||||
return seed;
|
||||
|
@ -770,7 +770,7 @@ bool QFontEngineFT::init(FaceId faceId, bool antialias, GlyphFormat format,
|
||||
PS_FontInfoRec psrec;
|
||||
// don't assume that type1 fonts are symbol fonts by default
|
||||
if (FT_Get_PS_Font_Info(freetype->face, &psrec) == FT_Err_Ok) {
|
||||
symbol = !fontDef.families.isEmpty() && bool(fontDef.families.first().contains("symbol"_L1, Qt::CaseInsensitive));
|
||||
symbol = !fontDef.families.isEmpty() && bool(fontDef.families.constFirst().contains("symbol"_L1, Qt::CaseInsensitive));
|
||||
}
|
||||
|
||||
freetype->computeSize(fontDef, &xsize, &ysize, &defaultGlyphSet.outline_drawing, &scalableBitmapScaleFactor);
|
||||
@ -1253,7 +1253,7 @@ QFontEngine::Properties QFontEngineFT::properties() const
|
||||
{
|
||||
Properties p = freetype->properties();
|
||||
if (p.postscriptName.isEmpty()) {
|
||||
p.postscriptName = QFontEngine::convertToPostscriptFontFamilyName(fontDef.families.first().toUtf8());
|
||||
p.postscriptName = QFontEngine::convertToPostscriptFontFamilyName(fontDef.families.constFirst().toUtf8());
|
||||
}
|
||||
|
||||
return freetype->properties();
|
||||
|
@ -2514,9 +2514,9 @@ void QFont::setFamilies(const QStringList &families)
|
||||
QDataStream &operator<<(QDataStream &s, const QFont &font)
|
||||
{
|
||||
if (s.version() == 1) {
|
||||
s << font.d->request.families.first().toLatin1();
|
||||
s << font.d->request.families.constFirst().toLatin1();
|
||||
} else {
|
||||
s << font.d->request.families.first();
|
||||
s << font.d->request.families.constFirst();
|
||||
if (s.version() >= QDataStream::Qt_5_4)
|
||||
s << font.d->request.styleName;
|
||||
}
|
||||
@ -2809,7 +2809,7 @@ QString QFontInfo::family() const
|
||||
{
|
||||
QFontEngine *engine = d->engineForScript(QChar::Script_Common);
|
||||
Q_ASSERT(engine != nullptr);
|
||||
return engine->fontDef.families.isEmpty() ? QString() : engine->fontDef.families.first();
|
||||
return engine->fontDef.families.isEmpty() ? QString() : engine->fontDef.families.constFirst();
|
||||
}
|
||||
|
||||
/*!
|
||||
|
@ -425,7 +425,7 @@ Q_GUI_EXPORT QDataStream &operator<<(QDataStream &stream, const QTextFormat &fmt
|
||||
|
||||
it = properties.find(QTextFormat::FontFamilies);
|
||||
if (it != properties.end()) {
|
||||
properties[QTextFormat::OldFontFamily] = QVariant(it.value().toStringList().first());
|
||||
properties[QTextFormat::OldFontFamily] = QVariant(it.value().toStringList().constFirst());
|
||||
properties.erase(it);
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user