summaryrefslogtreecommitdiffstats
path: root/src/gui
diff options
context:
space:
mode:
Diffstat (limited to 'src/gui')
-rw-r--r--src/gui/image/qicon.cpp2
-rw-r--r--src/gui/image/qiconloader.cpp2
-rw-r--r--src/gui/image/qimagepixmapcleanuphooks.cpp18
-rw-r--r--src/gui/image/qxpmhandler.cpp2
-rw-r--r--src/gui/itemmodels/qstandarditemmodel.cpp9
-rw-r--r--src/gui/kernel/qguiapplication.cpp4
-rw-r--r--src/gui/kernel/qkeysequence.cpp6
-rw-r--r--src/gui/kernel/qopenglcontext.cpp4
-rw-r--r--src/gui/kernel/qplatformintegration.cpp4
-rw-r--r--src/gui/kernel/qplatformscreen.cpp2
-rw-r--r--src/gui/kernel/qwindow.cpp8
-rw-r--r--src/gui/opengl/qopenglframebufferobject.cpp7
-rw-r--r--src/gui/opengl/qopenglgradientcache.cpp33
-rw-r--r--src/gui/painting/qpainter.cpp2
-rw-r--r--src/gui/painting/qpainterpath.cpp31
-rw-r--r--src/gui/painting/qpathclipper.cpp16
-rw-r--r--src/gui/painting/qpdf.cpp4
-rw-r--r--src/gui/text/qcssparser.cpp3
-rw-r--r--src/gui/text/qtextdocument_p.cpp21
-rw-r--r--src/gui/text/qtextdocumentfragment.cpp6
-rw-r--r--src/gui/text/qtextdocumentlayout.cpp24
-rw-r--r--src/gui/text/qtextengine.cpp4
-rw-r--r--src/gui/text/qtextformat.cpp2
-rw-r--r--src/gui/text/qtexthtmlparser.cpp2
-rw-r--r--src/gui/text/qtextodfwriter.cpp8
-rw-r--r--src/gui/text/qtexttable.cpp20
-rw-r--r--src/gui/util/qgridlayoutengine.cpp19
27 files changed, 130 insertions, 133 deletions
diff --git a/src/gui/image/qicon.cpp b/src/gui/image/qicon.cpp
index 620cbde25d..0dec4b512d 100644
--- a/src/gui/image/qicon.cpp
+++ b/src/gui/image/qicon.cpp
@@ -284,7 +284,7 @@ QPixmap QPixmapIconEngine::pixmap(const QSize &size, QIcon::Mode mode, QIcon::St
if (pm.isNull()) {
int idx = pixmaps.count();
while (--idx >= 0) {
- if (pe == &pixmaps[idx]) {
+ if (pe == &pixmaps.at(idx)) {
pixmaps.remove(idx);
break;
}
diff --git a/src/gui/image/qiconloader.cpp b/src/gui/image/qiconloader.cpp
index 7b6bfc60b3..2f24165069 100644
--- a/src/gui/image/qiconloader.cpp
+++ b/src/gui/image/qiconloader.cpp
@@ -296,7 +296,7 @@ QIconTheme::QIconTheme(const QString &themeName)
{
QFile themeIndex;
- QStringList iconDirs = QIcon::themeSearchPaths();
+ const QStringList iconDirs = QIcon::themeSearchPaths();
for ( int i = 0 ; i < iconDirs.size() ; ++i) {
QDir iconDir(iconDirs[i]);
QString themeDir = iconDir.path() + QLatin1Char('/') + themeName;
diff --git a/src/gui/image/qimagepixmapcleanuphooks.cpp b/src/gui/image/qimagepixmapcleanuphooks.cpp
index 10fa4303b2..f383e7a60e 100644
--- a/src/gui/image/qimagepixmapcleanuphooks.cpp
+++ b/src/gui/image/qimagepixmapcleanuphooks.cpp
@@ -84,38 +84,38 @@ void QImagePixmapCleanupHooks::removeImageHook(_qt_image_cleanup_hook_64 hook)
void QImagePixmapCleanupHooks::executePlatformPixmapModificationHooks(QPlatformPixmap* pmd)
{
- QImagePixmapCleanupHooks *h = qt_image_and_pixmap_cleanup_hooks();
+ const QImagePixmapCleanupHooks *h = qt_image_and_pixmap_cleanup_hooks();
// the global destructor for the pixmap and image hooks might have
// been called already if the app is "leaking" global
// pixmaps/images
if (!h)
return;
- for (int i = 0; i < h->pixmapModificationHooks.count(); ++i)
- h->pixmapModificationHooks[i](pmd);
+ for (auto hook : h->pixmapModificationHooks)
+ hook(pmd);
}
void QImagePixmapCleanupHooks::executePlatformPixmapDestructionHooks(QPlatformPixmap* pmd)
{
- QImagePixmapCleanupHooks *h = qt_image_and_pixmap_cleanup_hooks();
+ const QImagePixmapCleanupHooks *h = qt_image_and_pixmap_cleanup_hooks();
// the global destructor for the pixmap and image hooks might have
// been called already if the app is "leaking" global
// pixmaps/images
if (!h)
return;
- for (int i = 0; i < h->pixmapDestructionHooks.count(); ++i)
- h->pixmapDestructionHooks[i](pmd);
+ for (auto hook : h->pixmapDestructionHooks)
+ hook(pmd);
}
void QImagePixmapCleanupHooks::executeImageHooks(qint64 key)
{
- QImagePixmapCleanupHooks *h = qt_image_and_pixmap_cleanup_hooks();
+ const QImagePixmapCleanupHooks *h = qt_image_and_pixmap_cleanup_hooks();
// the global destructor for the pixmap and image hooks might have
// been called already if the app is "leaking" global
// pixmaps/images
if (!h)
return;
- for (int i = 0; i < h->imageHooks.count(); ++i)
- h->imageHooks[i](key);
+ for (auto hook : h->imageHooks)
+ hook(key);
}
diff --git a/src/gui/image/qxpmhandler.cpp b/src/gui/image/qxpmhandler.cpp
index 5ae8e893cb..c8dd589673 100644
--- a/src/gui/image/qxpmhandler.cpp
+++ b/src/gui/image/qxpmhandler.cpp
@@ -1154,7 +1154,7 @@ static bool write_xpm_image(const QImage &sourceImage, QIODevice *device, const
int cc = 0;
for(x=0; x<w; x++) {
int color = (int)(*(yp + x));
- QByteArray chars(xpm_color_name(cpp, colorMap[color]));
+ const QByteArray chars(xpm_color_name(cpp, colorMap[color]));
line[cc++] = QLatin1Char(chars[0]);
if (cpp > 1) {
line[cc++] = QLatin1Char(chars[1]);
diff --git a/src/gui/itemmodels/qstandarditemmodel.cpp b/src/gui/itemmodels/qstandarditemmodel.cpp
index 6f30f0ea25..3861eb8b40 100644
--- a/src/gui/itemmodels/qstandarditemmodel.cpp
+++ b/src/gui/itemmodels/qstandarditemmodel.cpp
@@ -3027,10 +3027,7 @@ QMimeData *QStandardItemModel::mimeData(const QModelIndexList &indexes) const
for (int i = 0; i < childList.count(); ++i) {
QStandardItem *chi = childList.at(i);
if (chi) {
- QSet<QStandardItem *>::iterator it = itemsSet.find(chi);
- if (it != itemsSet.end()) {
- itemsSet.erase(it);
- }
+ itemsSet.erase(itemsSet.constFind(chi));
stack.push(chi);
}
}
@@ -3139,13 +3136,13 @@ bool QStandardItemModel::dropMimeData(const QMimeData *data, Qt::DropAction acti
for (int i = 0; i < rows.count(); ++i)
rowsToInsert[rows.at(i)] = 1;
for (int i = 0; i < rowsToInsert.count(); ++i) {
- if (rowsToInsert[i] == 1){
+ if (rowsToInsert.at(i) == 1){
rowsToInsert[i] = dragRowCount;
++dragRowCount;
}
}
for (int i = 0; i < rows.count(); ++i)
- rows[i] = top + rowsToInsert[rows[i]];
+ rows[i] = top + rowsToInsert.at(rows.at(i));
QBitArray isWrittenTo(dragRowCount * dragColumnCount);
diff --git a/src/gui/kernel/qguiapplication.cpp b/src/gui/kernel/qguiapplication.cpp
index a9f0ab04a1..137310ffbd 100644
--- a/src/gui/kernel/qguiapplication.cpp
+++ b/src/gui/kernel/qguiapplication.cpp
@@ -1024,7 +1024,7 @@ QWindow *QGuiApplication::topLevelAt(const QPoint &pos)
// may repeat. Find only when there is more than one virtual desktop.
if (!windowScreen && screens.count() != primaryScreens.count()) {
for (int i = 1; i < screens.size(); ++i) {
- QScreen *screen = screens[i];
+ QScreen *screen = screens.at(i);
if (screen->geometry().contains(pos)) {
windowScreen = screen;
break;
@@ -2617,7 +2617,7 @@ void QGuiApplicationPrivate::processTouchEvent(QWindowSystemInterfacePrivate::To
if (b == Qt::NoButton)
self->synthesizedMousePoints.clear();
- QList<QTouchEvent::TouchPoint> touchPoints = touchEvent.touchPoints();
+ const QList<QTouchEvent::TouchPoint> &touchPoints = touchEvent.touchPoints();
if (eventType == QEvent::TouchBegin)
m_fakeMouseSourcePointId = touchPoints.first().id();
diff --git a/src/gui/kernel/qkeysequence.cpp b/src/gui/kernel/qkeysequence.cpp
index 8ccd85795b..f7771c252f 100644
--- a/src/gui/kernel/qkeysequence.cpp
+++ b/src/gui/kernel/qkeysequence.cpp
@@ -1160,15 +1160,15 @@ int QKeySequencePrivate::decodeString(const QString &str, QKeySequence::Sequence
int fnum = 0;
if (accel.length() == 1) {
#if defined(Q_OS_MACX)
- int qtKey = qtkeyForMacSymbol(accel[0]);
+ int qtKey = qtkeyForMacSymbol(accel.at(0));
if (qtKey != -1) {
ret |= qtKey;
} else
#endif
{
- ret |= accel[0].toUpper().unicode();
+ ret |= accel.at(0).toUpper().unicode();
}
- } else if (accel[0] == QLatin1Char('f') && (fnum = accel.mid(1).toInt()) && (fnum >= 1) && (fnum <= 35)) {
+ } else if (accel.at(0) == QLatin1Char('f') && (fnum = accel.mid(1).toInt()) >= 1 && fnum <= 35) {
ret |= Qt::Key_F1 + fnum - 1;
} else {
// For NativeText, check the traslation table first,
diff --git a/src/gui/kernel/qopenglcontext.cpp b/src/gui/kernel/qopenglcontext.cpp
index 59bf2bb065..0f7bbfd2e1 100644
--- a/src/gui/kernel/qopenglcontext.cpp
+++ b/src/gui/kernel/qopenglcontext.cpp
@@ -1409,7 +1409,7 @@ void QOpenGLContextGroupPrivate::removeContext(QOpenGLContext *ctx)
m_shares.removeOne(ctx);
if (ctx == m_context && !m_shares.isEmpty())
- m_context = m_shares.first();
+ m_context = m_shares.constFirst();
if (!m_refs.deref()) {
cleanup();
@@ -1573,7 +1573,7 @@ QOpenGLMultiGroupSharedResource::~QOpenGLMultiGroupSharedResource()
#endif
for (int i = 0; i < m_groups.size(); ++i) {
if (!m_groups.at(i)->shares().isEmpty()) {
- QOpenGLContext *context = m_groups.at(i)->shares().first();
+ QOpenGLContext *context = m_groups.at(i)->shares().constFirst();
QOpenGLSharedResource *resource = value(context);
if (resource)
resource->free();
diff --git a/src/gui/kernel/qplatformintegration.cpp b/src/gui/kernel/qplatformintegration.cpp
index a0e65654a6..3490e786a8 100644
--- a/src/gui/kernel/qplatformintegration.cpp
+++ b/src/gui/kernel/qplatformintegration.cpp
@@ -474,11 +474,11 @@ void QPlatformIntegration::screenAdded(QPlatformScreen *ps, bool isPrimary)
void QPlatformIntegration::removeScreen(QScreen *screen)
{
- const bool wasPrimary = (!QGuiApplicationPrivate::screen_list.isEmpty() && QGuiApplicationPrivate::screen_list[0] == screen);
+ const bool wasPrimary = (!QGuiApplicationPrivate::screen_list.isEmpty() && QGuiApplicationPrivate::screen_list.at(0) == screen);
QGuiApplicationPrivate::screen_list.removeOne(screen);
if (wasPrimary && qGuiApp && !QGuiApplicationPrivate::screen_list.isEmpty())
- emit qGuiApp->primaryScreenChanged(QGuiApplicationPrivate::screen_list[0]);
+ emit qGuiApp->primaryScreenChanged(QGuiApplicationPrivate::screen_list.at(0));
}
/*!
diff --git a/src/gui/kernel/qplatformscreen.cpp b/src/gui/kernel/qplatformscreen.cpp
index 8450c6a083..3c1552c31e 100644
--- a/src/gui/kernel/qplatformscreen.cpp
+++ b/src/gui/kernel/qplatformscreen.cpp
@@ -93,7 +93,7 @@ QPixmap QPlatformScreen::grabWindow(WId window, int x, int y, int width, int hei
*/
QWindow *QPlatformScreen::topLevelAt(const QPoint & pos) const
{
- QWindowList list = QGuiApplication::topLevelWindows();
+ const QWindowList list = QGuiApplication::topLevelWindows();
for (int i = list.size()-1; i >= 0; --i) {
QWindow *w = list[i];
if (w->isVisible() && QHighDpi::toNativePixels(w->geometry(), w).contains(pos))
diff --git a/src/gui/kernel/qwindow.cpp b/src/gui/kernel/qwindow.cpp
index 81310ae2a2..fa26fd77a3 100644
--- a/src/gui/kernel/qwindow.cpp
+++ b/src/gui/kernel/qwindow.cpp
@@ -1688,11 +1688,9 @@ void QWindow::destroy()
if (QGuiApplicationPrivate::currentMousePressWindow == this)
QGuiApplicationPrivate::currentMousePressWindow = parent();
- for (int i = 0; i < QGuiApplicationPrivate::tabletDevicePoints.size(); ++i) {
- QGuiApplicationPrivate::TabletPointData &pointData = QGuiApplicationPrivate::tabletDevicePoints[i];
- if (pointData.target == this)
- pointData.target = parent();
- }
+ for (int i = 0; i < QGuiApplicationPrivate::tabletDevicePoints.size(); ++i)
+ if (QGuiApplicationPrivate::tabletDevicePoints.at(i).target == this)
+ QGuiApplicationPrivate::tabletDevicePoints[i].target = parent();
bool wasVisible = isVisible();
d->visibilityOnDestroy = wasVisible && d->platformWindow;
diff --git a/src/gui/opengl/qopenglframebufferobject.cpp b/src/gui/opengl/qopenglframebufferobject.cpp
index 597d347915..aa0520f695 100644
--- a/src/gui/opengl/qopenglframebufferobject.cpp
+++ b/src/gui/opengl/qopenglframebufferobject.cpp
@@ -1078,7 +1078,7 @@ bool QOpenGLFramebufferObject::bind()
if (d->format.samples() == 0) {
// Create new textures to replace the ones stolen via takeTexture().
for (int i = 0; i < d->colorAttachments.count(); ++i) {
- if (!d->colorAttachments[i].guard)
+ if (!d->colorAttachments.at(i).guard)
d->initTexture(i);
}
}
@@ -1211,10 +1211,11 @@ GLuint QOpenGLFramebufferObject::takeTexture(int colorAttachmentIndex)
QOpenGLContext *current = QOpenGLContext::currentContext();
if (current && current->shareGroup() == d->fbo_guard->group() && isBound())
release();
- id = d->colorAttachments[colorAttachmentIndex].guard ? d->colorAttachments[colorAttachmentIndex].guard->id() : 0;
+ auto &guard = d->colorAttachments[colorAttachmentIndex].guard;
+ id = guard ? guard->id() : 0;
// Do not call free() on texture_guard, just null it out.
// This way the texture will not be deleted when the guard is destroyed.
- d->colorAttachments[colorAttachmentIndex].guard = 0;
+ guard = 0;
}
return id;
}
diff --git a/src/gui/opengl/qopenglgradientcache.cpp b/src/gui/opengl/qopenglgradientcache.cpp
index c135489379..58dcbed50a 100644
--- a/src/gui/opengl/qopenglgradientcache.cpp
+++ b/src/gui/opengl/qopenglgradientcache.cpp
@@ -108,7 +108,7 @@ GLuint QOpenGL2GradientCache::getBuffer(const QGradient &gradient, qreal opacity
{
quint64 hash_val = 0;
- QGradientStops stops = gradient.stops();
+ const QGradientStops stops = gradient.stops();
for (int i = 0; i < stops.size() && i <= 2; i++)
hash_val += stops[i].second.rgba();
@@ -170,16 +170,12 @@ GLuint QOpenGL2GradientCache::addCacheElement(quint64 hash_val, const QGradient
void QOpenGL2GradientCache::generateGradientColorTable(const QGradient& gradient, QRgba64 *colorTable, int size, qreal opacity) const
{
int pos = 0;
- QGradientStops s = gradient.stops();
- QVector<QRgba64> colors(s.size());
-
- for (int i = 0; i < s.size(); ++i)
- colors[i] = s[i].second.rgba64();
+ const QGradientStops s = gradient.stops();
bool colorInterpolation = (gradient.interpolationMode() == QGradient::ColorInterpolation);
uint alpha = qRound(opacity * 256);
- QRgba64 current_color = combineAlpha256(colors[0], alpha);
+ QRgba64 current_color = combineAlpha256(s[0].second.rgba64(), alpha);
qreal incr = 1.0 / qreal(size);
qreal fpos = 1.5 * incr;
colorTable[pos++] = qPremultiply(current_color);
@@ -193,9 +189,10 @@ void QOpenGL2GradientCache::generateGradientColorTable(const QGradient& gradient
if (colorInterpolation)
current_color = qPremultiply(current_color);
- for (int i = 0; i < s.size() - 1; ++i) {
+ const int sLast = s.size() - 1;
+ for (int i = 0; i < sLast; ++i) {
qreal delta = 1/(s[i+1].first - s[i].first);
- QRgba64 next_color = combineAlpha256(colors[i+1], alpha);
+ QRgba64 next_color = combineAlpha256(s[i + 1].second.rgba64(), alpha);
if (colorInterpolation)
next_color = qPremultiply(next_color);
@@ -214,7 +211,7 @@ void QOpenGL2GradientCache::generateGradientColorTable(const QGradient& gradient
Q_ASSERT(s.size() > 0);
- QRgba64 last_color = qPremultiply(combineAlpha256(colors[s.size() - 1], alpha));
+ QRgba64 last_color = qPremultiply(combineAlpha256(s[sLast].second.rgba64(), alpha));
for (;pos < size; ++pos)
colorTable[pos] = last_color;
@@ -225,16 +222,13 @@ void QOpenGL2GradientCache::generateGradientColorTable(const QGradient& gradient
void QOpenGL2GradientCache::generateGradientColorTable(const QGradient& gradient, uint *colorTable, int size, qreal opacity) const
{
int pos = 0;
- QGradientStops s = gradient.stops();
- QVector<uint> colors(s.size());
-
- for (int i = 0; i < s.size(); ++i)
- colors[i] = s[i].second.rgba(); // Qt LIES! It returns ARGB (on little-endian AND on big-endian)
+ const QGradientStops s = gradient.stops();
bool colorInterpolation = (gradient.interpolationMode() == QGradient::ColorInterpolation);
uint alpha = qRound(opacity * 256);
- uint current_color = ARGB_COMBINE_ALPHA(colors[0], alpha);
+ // Qt LIES! It returns ARGB (on little-endian AND on big-endian)
+ uint current_color = ARGB_COMBINE_ALPHA(s[0].second.rgba(), alpha);
qreal incr = 1.0 / qreal(size);
qreal fpos = 1.5 * incr;
colorTable[pos++] = ARGB2RGBA(qPremultiply(current_color));
@@ -248,9 +242,10 @@ void QOpenGL2GradientCache::generateGradientColorTable(const QGradient& gradient
if (colorInterpolation)
current_color = qPremultiply(current_color);
- for (int i = 0; i < s.size() - 1; ++i) {
+ const int sLast = s.size() - 1;
+ for (int i = 0; i < sLast; ++i) {
qreal delta = 1/(s[i+1].first - s[i].first);
- uint next_color = ARGB_COMBINE_ALPHA(colors[i+1], alpha);
+ uint next_color = ARGB_COMBINE_ALPHA(s[i + 1].second.rgba(), alpha);
if (colorInterpolation)
next_color = qPremultiply(next_color);
@@ -269,7 +264,7 @@ void QOpenGL2GradientCache::generateGradientColorTable(const QGradient& gradient
Q_ASSERT(s.size() > 0);
- uint last_color = ARGB2RGBA(qPremultiply(ARGB_COMBINE_ALPHA(colors[s.size() - 1], alpha)));
+ uint last_color = ARGB2RGBA(qPremultiply(ARGB_COMBINE_ALPHA(s[sLast].second.rgba(), alpha)));
for (;pos < size; ++pos)
colorTable[pos] = last_color;
diff --git a/src/gui/painting/qpainter.cpp b/src/gui/painting/qpainter.cpp
index 8bc15bf777..9cad9e0a1d 100644
--- a/src/gui/painting/qpainter.cpp
+++ b/src/gui/painting/qpainter.cpp
@@ -2469,7 +2469,7 @@ void QPainter::setClipping(bool enable)
// we can't enable clipping if we don't have a clip
if (enable
- && (d->state->clipInfo.isEmpty() || d->state->clipInfo.last().operation == Qt::NoClip))
+ && (d->state->clipInfo.isEmpty() || d->state->clipInfo.constLast().operation == Qt::NoClip))
return;
d->state->clipEnabled = enable;
diff --git a/src/gui/painting/qpainterpath.cpp b/src/gui/painting/qpainterpath.cpp
index ba14a45d4a..5b91266b64 100644
--- a/src/gui/painting/qpainterpath.cpp
+++ b/src/gui/painting/qpainterpath.cpp
@@ -690,7 +690,7 @@ void QPainterPath::moveTo(const QPointF &p)
d->require_moveTo = false;
- if (d->elements.last().type == MoveToElement) {
+ if (d->elements.constLast().type == MoveToElement) {
d->elements.last().x = p.x();
d->elements.last().y = p.y();
} else {
@@ -738,7 +738,7 @@ void QPainterPath::lineTo(const QPointF &p)
QPainterPathData *d = d_func();
Q_ASSERT(!d->elements.isEmpty());
d->maybeMoveTo();
- if (p == QPointF(d->elements.last()))
+ if (p == QPointF(d->elements.constLast()))
return;
Element elm = { p.x(), p.y(), LineToElement };
d->elements.append(elm);
@@ -801,7 +801,7 @@ void QPainterPath::cubicTo(const QPointF &c1, const QPointF &c2, const QPointF &
// Abort on empty curve as a stroker cannot handle this and the
// curve is irrelevant anyway.
- if (d->elements.last() == c1 && c1 == c2 && c2 == e)
+ if (d->elements.constLast() == c1 && c1 == c2 && c2 == e)
return;
d->maybeMoveTo();
@@ -984,7 +984,7 @@ QPointF QPainterPath::currentPosition() const
{
return !d_ptr || d_func()->elements.isEmpty()
? QPointF()
- : QPointF(d_func()->elements.last().x, d_func()->elements.last().y);
+ : QPointF(d_func()->elements.constLast().x, d_func()->elements.constLast().y);
}
@@ -1073,7 +1073,7 @@ void QPainterPath::addPolygon(const QPolygonF &polygon)
d_func()->elements.reserve(d_func()->elements.size() + polygon.size());
- moveTo(polygon.first());
+ moveTo(polygon.constFirst());
for (int i=1; i<polygon.size(); ++i) {
Element elm = { polygon.at(i).x(), polygon.at(i).y(), LineToElement };
d_func()->elements << elm;
@@ -1178,12 +1178,12 @@ void QPainterPath::addText(const QPointF &point, const QFont &f, const QString &
QVarLengthArray<int> visualOrder(nItems);
QVarLengthArray<uchar> levels(nItems);
for (int i = 0; i < nItems; ++i)
- levels[i] = eng->layoutData->items[i].analysis.bidiLevel;
+ levels[i] = eng->layoutData->items.at(i).analysis.bidiLevel;
QTextEngine::bidiReorder(nItems, levels.data(), visualOrder.data());
for (int i = 0; i < nItems; ++i) {
int item = visualOrder[i];
- QScriptItem &si = eng->layoutData->items[item];
+ const QScriptItem &si = eng->layoutData->items.at(item);
if (si.analysis.flags < QScriptAnalysis::TabOrObject) {
QGlyphLayout glyphs = eng->shapedGlyphs(&si);
@@ -1230,7 +1230,7 @@ void QPainterPath::addPath(const QPainterPath &other)
QPainterPathData *d = reinterpret_cast<QPainterPathData *>(d_func());
// Remove last moveto so we don't get multiple moveto's
- if (d->elements.last().type == MoveToElement)
+ if (d->elements.constLast().type == MoveToElement)
d->elements.remove(d->elements.size()-1);
// Locate where our own current subpath will start after the other path is added.
@@ -1261,7 +1261,7 @@ void QPainterPath::connectPath(const QPainterPath &other)
QPainterPathData *d = reinterpret_cast<QPainterPathData *>(d_func());
// Remove last moveto so we don't get multiple moveto's
- if (d->elements.last().type == MoveToElement)
+ if (d->elements.constLast().type == MoveToElement)
d->elements.remove(d->elements.size()-1);
// Locate where our own current subpath will start after the other path is added.
@@ -1273,7 +1273,7 @@ void QPainterPath::connectPath(const QPainterPath &other)
d->elements[first].type = LineToElement;
// avoid duplicate points
- if (first > 0 && QPointF(d->elements[first]) == QPointF(d->elements[first - 1])) {
+ if (first > 0 && QPointF(d->elements.at(first)) == QPointF(d->elements.at(first - 1))) {
d->elements.remove(first--);
--cStart;
}
@@ -1686,8 +1686,9 @@ QList<QPolygonF> QPainterPath::toFillPolygons(const QTransform &matrix) const
int isect_j = current_isects.at(j);
if (isect_j == i)
continue;
- for (int k=0; k<isects[isect_j].size(); ++k) {
- int isect_k = isects[isect_j][k];
+ const QVector<int> &isects_j = isects.at(isect_j);
+ for (int k = 0, size = isects_j.size(); k < size; ++k) {
+ int isect_k = isects_j.at(k);
if (isect_k != i && !isects.at(i).contains(isect_k)) {
isects[i] += isect_k;
}
@@ -1709,7 +1710,7 @@ QList<QPolygonF> QPainterPath::toFillPolygons(const QTransform &matrix) const
// Join the intersected subpaths as rewinded polygons
for (int i=0; i<count; ++i) {
- const QVector<int> &subpath_list = isects[i];
+ const QVector<int> &subpath_list = isects.at(i);
if (!subpath_list.isEmpty()) {
QPolygonF buildUp;
for (int j=0; j<subpath_list.size(); ++j) {
@@ -1718,7 +1719,7 @@ QList<QPolygonF> QPainterPath::toFillPolygons(const QTransform &matrix) const
if (!subpath.isClosed())
buildUp += subpath.first();
if (!buildUp.isClosed())
- buildUp += buildUp.first();
+ buildUp += buildUp.constFirst();
}
polys += buildUp;
}
@@ -2790,7 +2791,7 @@ void QPainterPathStroker::setDashOffset(qreal offset)
QPolygonF QPainterPath::toFillPolygon(const QTransform &matrix) const
{
- QList<QPolygonF> flats = toSubpathPolygons(matrix);
+ const QList<QPolygonF> flats = toSubpathPolygons(matrix);
QPolygonF polygon;
if (flats.isEmpty())
return polygon;
diff --git a/src/gui/painting/qpathclipper.cpp b/src/gui/painting/qpathclipper.cpp
index 48ae3cfc80..4f2b59c775 100644
--- a/src/gui/painting/qpathclipper.cpp
+++ b/src/gui/painting/qpathclipper.cpp
@@ -1648,7 +1648,7 @@ bool QPathClipper::doClip(QWingedEdge &list, ClipperMode mode)
#ifdef QDEBUG_CLIPPER
printf("sorted y coords:\n");
for (int i = 0; i < y_coords.size(); ++i) {
- printf("%.9f\n", y_coords[i]);
+ printf("%.9f\n", y_coords.at(i));
}
#endif
@@ -1686,23 +1686,23 @@ bool QPathClipper::doClip(QWingedEdge &list, ClipperMode mode)
QPathVertex *b = list.vertex(edge->second);
// FIXME: this can be optimized by using binary search
- const int first = qFuzzyFind(y_coords.begin(), y_coords.end(), qMin(a->y, b->y)) - y_coords.begin();
- const int last = qFuzzyFind(y_coords.begin() + first, y_coords.end(), qMax(a->y, b->y)) - y_coords.begin();
+ const int first = qFuzzyFind(y_coords.cbegin(), y_coords.cend(), qMin(a->y, b->y)) - y_coords.cbegin();
+ const int last = qFuzzyFind(y_coords.cbegin() + first, y_coords.cend(), qMax(a->y, b->y)) - y_coords.cbegin();
Q_ASSERT(first < y_coords.size() - 1);
Q_ASSERT(last < y_coords.size());
- qreal bestY = 0.5 * (y_coords[first] + y_coords[first+1]);
- qreal biggestGap = y_coords[first+1] - y_coords[first];
-
+ qreal biggestGap = y_coords.at(first + 1) - y_coords.at(first);
+ int bestIdx = first;
for (int i = first + 1; i < last; ++i) {
- qreal gap = y_coords[i+1] - y_coords[i];
+ qreal gap = y_coords.at(i + 1) - y_coords.at(i);
if (gap > biggestGap) {
- bestY = 0.5 * (y_coords[i] + y_coords[i+1]);
+ bestIdx = i;
biggestGap = gap;
}
}
+ const qreal bestY = 0.5 * (y_coords.at(bestIdx) + y_coords.at(bestIdx + 1));
#ifdef QDEBUG_CLIPPER
printf("y: %.9f, gap: %.9f\n", bestY, biggestGap);
diff --git a/src/gui/painting/qpdf.cpp b/src/gui/painting/qpdf.cpp
index 9e38c5272f..d568dca6b9 100644
--- a/src/gui/painting/qpdf.cpp
+++ b/src/gui/painting/qpdf.cpp
@@ -1675,7 +1675,7 @@ void QPdfEnginePrivate::writePage()
uint resources = requestObject();
uint annots = requestObject();
- addXrefEntry(pages.last());
+ addXrefEntry(pages.constLast());
xprintf("<<\n"
"/Type /Page\n"
"/Parent %d 0 R\n"
@@ -1768,7 +1768,7 @@ void QPdfEnginePrivate::writeTail()
">>\n"
"startxref\n%d\n"
"%%%%EOF\n",
- xrefPositions.size()-1, info, catalog, xrefPositions.last());
+ xrefPositions.size()-1, info, catalog, xrefPositions.constLast());
}
int QPdfEnginePrivate::addXrefEntry(int object, bool printostr)
diff --git a/src/gui/text/qcssparser.cpp b/src/gui/text/qcssparser.cpp
index 53d4e3fa36..d455a74d96 100644
--- a/src/gui/text/qcssparser.cpp
+++ b/src/gui/text/qcssparser.cpp
@@ -1507,7 +1507,7 @@ QRect Declaration::rectValue() const
const QCss::Value &v = d->values.at(0);
if (v.type != Value::Function)
return QRect();
- QStringList func = v.variant.toStringList();
+ const QStringList func = v.variant.toStringList();
if (func.count() != 2 || func.at(0).compare(QLatin1String("rect")) != 0)
return QRect();
QStringList args = func[1].split(QLatin1Char(' '), QString::SkipEmptyParts);
@@ -1653,6 +1653,7 @@ Qt::Alignment Declaration::alignmentValue() const
void Declaration::borderImageValue(QString *image, int *cuts,
TileMode *h, TileMode *v) const
{
+ const DeclarationData *d = this->d.data(); // make it const and shadow d
*image = uriValue();
for (int i = 0; i < 4; i++)
cuts[i] = -1;
diff --git a/src/gui/text/qtextdocument_p.cpp b/src/gui/text/qtextdocument_p.cpp
index 93071aaf59..ffc5d7418b 100644
--- a/src/gui/text/qtextdocument_p.cpp
+++ b/src/gui/text/qtextdocument_p.cpp
@@ -1006,9 +1006,9 @@ int QTextDocumentPrivate::undoRedo(bool undo)
bool inBlock = (
undoState > 0
&& undoState < undoStack.size()
- && undoStack[undoState].block_part
- && undoStack[undoState-1].block_part
- && !undoStack[undoState-1].block_end
+ && undoStack.at(undoState).block_part
+ && undoStack.at(undoState - 1).block_part
+ && !undoStack.at(undoState - 1).block_end
);
if (!inBlock)
break;
@@ -1074,12 +1074,13 @@ void QTextDocumentPrivate::appendUndoItem(const QTextUndoCommand &c)
if (!undoStack.isEmpty() && modified) {
- QTextUndoCommand &last = undoStack[undoState - 1];
+ const int lastIdx = undoState - 1;
+ const QTextUndoCommand &last = undoStack.at(lastIdx);
if ( (last.block_part && c.block_part && !last.block_end) // part of the same block => can merge
|| (!c.block_part && !last.block_part)) { // two single undo items => can merge
- if (last.tryMerge(c))
+ if (undoStack[lastIdx].tryMerge(c))
return;
}
}
@@ -1101,7 +1102,7 @@ void QTextDocumentPrivate::clearUndoRedoStacks(QTextDocument::Stacks stacksToCle
bool redoCommandsAvailable = undoState != undoStack.size();
if (stacksToClear == QTextDocument::UndoStack && undoCommandsAvailable) {
for (int i = 0; i < undoState; ++i) {
- QTextUndoCommand c = undoStack[undoState];
+ QTextUndoCommand c = undoStack.at(undoState);
if (c.command & QTextUndoCommand::Custom)
delete c.custom;
}
@@ -1113,7 +1114,7 @@ void QTextDocumentPrivate::clearUndoRedoStacks(QTextDocument::Stacks stacksToCle
} else if (stacksToClear == QTextDocument::RedoStack
&& redoCommandsAvailable) {
for (int i = undoState; i < undoStack.size(); ++i) {
- QTextUndoCommand c = undoStack[i];
+ QTextUndoCommand c = undoStack.at(i);
if (c.command & QTextUndoCommand::Custom)
delete c.custom;
}
@@ -1123,7 +1124,7 @@ void QTextDocumentPrivate::clearUndoRedoStacks(QTextDocument::Stacks stacksToCle
} else if (stacksToClear == QTextDocument::UndoAndRedoStacks
&& !undoStack.isEmpty()) {
for (int i = 0; i < undoStack.size(); ++i) {
- QTextUndoCommand c = undoStack[i];
+ QTextUndoCommand c = undoStack.at(i);
if (c.command & QTextUndoCommand::Custom)
delete c.custom;
}
@@ -1186,8 +1187,8 @@ void QTextDocumentPrivate::endEditBlock()
return;
if (undoEnabled && undoState > 0) {
- const bool wasBlocking = !undoStack[undoState - 1].block_end;
- if (undoStack[undoState - 1].block_part) {
+ const bool wasBlocking = !undoStack.at(undoState - 1).block_end;
+ if (undoStack.at(undoState - 1).block_part) {
undoStack[undoState - 1].block_end = true;
if (wasBlocking)
emit document()->undoCommandAdded();
diff --git a/src/gui/text/qtextdocumentfragment.cpp b/src/gui/text/qtextdocumentfragment.cpp
index f8f4e454e0..a1a562c839 100644
--- a/src/gui/text/qtextdocumentfragment.cpp
+++ b/src/gui/text/qtextdocumentfragment.cpp
@@ -882,7 +882,7 @@ QTextHtmlImporter::Table QTextHtmlImporter::scanTable(int tableNodeIdx)
if (at(cell).isTableCell()) {
// skip all columns with spans from previous rows
while (colsInRow < rowColSpanForColumn.size()) {
- const RowColSpanInfo &spanInfo = rowColSpanForColumn[colsInRow];
+ const RowColSpanInfo &spanInfo = rowColSpanForColumn.at(colsInRow);
if (spanInfo.row + spanInfo.rowSpan > effectiveRow) {
Q_ASSERT(spanInfo.col == colsInRow);
@@ -1081,8 +1081,8 @@ QTextHtmlImporter::ProcessNodeResult QTextHtmlImporter::processBlockNode()
&& indent != 0
&& (lists.isEmpty()
|| !hasBlock
- || !lists.last().list
- || lists.last().list->itemNumber(cursor.block()) == -1
+ || !lists.constLast().list
+ || lists.constLast().list->itemNumber(cursor.block()) == -1
)
) {
block.setIndent(indent);
diff --git a/src/gui/text/qtextdocumentlayout.cpp b/src/gui/text/qtextdocumentlayout.cpp
index 9863955a55..b6cbd9617f 100644
--- a/src/gui/text/qtextdocumentlayout.cpp
+++ b/src/gui/text/qtextdocumentlayout.cpp
@@ -265,7 +265,7 @@ void QTextTableData::updateTableSize()
const QFixed effectiveLeftMargin = this->leftMargin + border + padding;
const QFixed effectiveRightMargin = this->rightMargin + border + padding;
size.height = contentsHeight == -1
- ? rowPositions.last() + heights.last() + padding + border + cellSpacing + effectiveBottomMargin
+ ? rowPositions.constLast() + heights.constLast() + padding + border + cellSpacing + effectiveBottomMargin
: effectiveTopMargin + contentsHeight + effectiveBottomMargin;
size.width = effectiveLeftMargin + contentsWidth + effectiveRightMargin;
}
@@ -1238,7 +1238,7 @@ void QTextDocumentLayoutPrivate::drawFlow(const QPointF &offset, QPainter *paint
// if we're past what is already laid out then we're better off
// not trying to draw things that may not be positioned correctly yet
- if (currentPosInDoc >= checkPoints.last().positionInFrame)
+ if (currentPosInDoc >= checkPoints.constLast().positionInFrame)
break;
if (lastVisibleCheckPoint != checkPoints.end()
@@ -1798,7 +1798,7 @@ recalc_minmax_widths:
td->columnPositions[i] = td->columnPositions.at(i-1) + td->widths.at(i-1) + 2 * td->border + cellSpacing;
// - margin to compensate the + margin in columnPositions[0]
- const QFixed contentsWidth = td->columnPositions.last() + td->widths.last() + td->padding + td->border + cellSpacing - leftMargin;
+ const QFixed contentsWidth = td->columnPositions.constLast() + td->widths.constLast() + td->padding + td->border + cellSpacing - leftMargin;
// if the table is too big and causes an overflow re-do the layout with WrapAnywhere as wrap
// mode
@@ -1845,14 +1845,14 @@ recalc_minmax_widths:
td->calcRowPosition(r);
const int tableStartPage = (absoluteTableY / pageHeight).truncate();
- const int currentPage = ((td->rowPositions[r] + absoluteTableY) / pageHeight).truncate();
+ const int currentPage = ((td->rowPositions.at(r) + absoluteTableY) / pageHeight).truncate();
const QFixed pageBottom = (currentPage + 1) * pageHeight - td->effectiveBottomMargin - absoluteTableY - cellSpacing - td->border;
const QFixed pageTop = currentPage * pageHeight + td->effectiveTopMargin - absoluteTableY + cellSpacing + td->border;
const QFixed nextPageTop = pageTop + pageHeight;
- if (td->rowPositions[r] > pageBottom)
+ if (td->rowPositions.at(r) > pageBottom)
td->rowPositions[r] = nextPageTop;
- else if (td->rowPositions[r] < pageTop)
+ else if (td->rowPositions.at(r) < pageTop)
td->rowPositions[r] = pageTop;
bool dropRowToNextPage = true;
@@ -1863,7 +1863,7 @@ recalc_minmax_widths:
QFixed dropDistance = 0;
relayout:
- const int rowStartPage = ((td->rowPositions[r] + absoluteTableY) / pageHeight).truncate();
+ const int rowStartPage = ((td->rowPositions.at(r) + absoluteTableY) / pageHeight).truncate();
// if any of the header rows or the first non-header row start on the next page
// then the entire header should be dropped
if (r <= headerRowCount && rowStartPage > tableStartPage && !hasDroppedTable) {
@@ -1927,13 +1927,13 @@ relayout:
}
if (rowCellCount > 0 && dropRowToNextPage) {
- dropDistance = nextPageTop - td->rowPositions[r];
+ dropDistance = nextPageTop - td->rowPositions.at(r);
td->rowPositions[r] = nextPageTop;
td->heights[r] = 0;
dropRowToNextPage = false;
cellHeights.resize(cellCountBeforeRow);
if (r > headerRowCount)
- td->heights[r-1] = pageBottom - td->rowPositions[r-1];
+ td->heights[r - 1] = pageBottom - td->rowPositions.at(r - 1);
goto relayout;
}
@@ -1944,7 +1944,7 @@ relayout:
}
if (r == headerRowCount - 1) {
- td->headerHeight = td->rowPositions[r] + td->heights[r] - td->rowPositions[0] + td->cellSpacing + 2 * td->border;
+ td->headerHeight = td->rowPositions.at(r) + td->heights.at(r) - td->rowPositions.at(0) + td->cellSpacing + 2 * td->border;
td->headerHeight -= td->headerHeight * (td->headerHeight / pageHeight).truncate();
td->effectiveTopMargin += td->headerHeight;
}
@@ -2304,7 +2304,7 @@ void QTextDocumentLayoutPrivate::layoutFlow(QTextFrame::Iterator it, QTextLayout
docPos = it.currentBlock().position();
if (inRootFrame) {
- if (qAbs(layoutStruct->y - checkPoints.last().y) > 2000) {
+ if (qAbs(layoutStruct->y - checkPoints.constLast().y) > 2000) {
QFixed left, right;
floatMargins(layoutStruct->y, layoutStruct, &left, &right);
if (left == layoutStruct->x_left && right == layoutStruct->x_right) {
@@ -2554,7 +2554,7 @@ void QTextDocumentLayoutPrivate::layoutFlow(QTextFrame::Iterator it, QTextLayout
checkPoints.append(cp);
checkPoints.reserve(checkPoints.size());
} else {
- currentLazyLayoutPosition = checkPoints.last().positionInFrame;
+ currentLazyLayoutPosition = checkPoints.constLast().positionInFrame;
// #######
//checkPoints.last().positionInFrame = q->document()->docHandle()->length();
}
diff --git a/src/gui/text/qtextengine.cpp b/src/gui/text/qtextengine.cpp
index 7864975091..7ee02b71c9 100644
--- a/src/gui/text/qtextengine.cpp
+++ b/src/gui/text/qtextengine.cpp
@@ -3274,7 +3274,7 @@ int QTextEngine::endOfLine(int lineNum)
insertionPointsForLine(lineNum, insertionPoints);
if (insertionPoints.size() > 0)
- return insertionPoints.last();
+ return insertionPoints.constLast();
return 0;
}
@@ -3284,7 +3284,7 @@ int QTextEngine::beginningOfLine(int lineNum)
insertionPointsForLine(lineNum, insertionPoints);
if (insertionPoints.size() > 0)
- return insertionPoints.first();
+ return insertionPoints.constFirst();
return 0;
}
diff --git a/src/gui/text/qtextformat.cpp b/src/gui/text/qtextformat.cpp
index 49ec9ca768..402bd75a76 100644
--- a/src/gui/text/qtextformat.cpp
+++ b/src/gui/text/qtextformat.cpp
@@ -3462,7 +3462,7 @@ void QTextFormatCollection::setDefaultFont(const QFont &f)
{
defaultFnt = f;
for (int i = 0; i < formats.count(); ++i)
- if (formats[i].d)
+ if (formats.at(i).d)
formats[i].d->resolveFont(defaultFnt);
}
diff --git a/src/gui/text/qtexthtmlparser.cpp b/src/gui/text/qtexthtmlparser.cpp
index 576ff7d935..103a208c26 100644
--- a/src/gui/text/qtexthtmlparser.cpp
+++ b/src/gui/text/qtexthtmlparser.cpp
@@ -665,7 +665,7 @@ void QTextHtmlParser::parseTag()
if (hasPrefix(QLatin1Char('/'))) {
if (nodes.last().id == Html_style) {
#ifndef QT_NO_CSSPARSER
- QCss::Parser parser(nodes.last().text);
+ QCss::Parser parser(nodes.constLast().text);
QCss::StyleSheet sheet;
sheet.origin = QCss::StyleSheetOrigin_Author;
parser.parse(&sheet, Qt::CaseInsensitive);
diff --git a/src/gui/text/qtextodfwriter.cpp b/src/gui/text/qtextodfwriter.cpp
index bd2a9d5183..ad537b7126 100644
--- a/src/gui/text/qtextodfwriter.cpp
+++ b/src/gui/text/qtextodfwriter.cpp
@@ -812,10 +812,10 @@ bool QTextOdfWriter::writeAll()
}
// add objects for lists, frames and tables
- QVector<QTextFormat> allFormats = m_document->allFormats();
- QList<int> copy = formats.toList();
- for (QList<int>::Iterator iter = copy.begin(); iter != copy.end(); ++iter) {
- QTextObject *object = m_document->objectForFormat(allFormats[*iter]);
+ const QVector<QTextFormat> allFormats = m_document->allFormats();
+ const QList<int> copy = formats.toList();
+ for (auto index : copy) {
+ QTextObject *object = m_document->objectForFormat(allFormats[index]);
if (object)
formats << object->formatIndex();
}
diff --git a/src/gui/text/qtexttable.cpp b/src/gui/text/qtexttable.cpp
index 2d5636e1d9..e4a3c2b915 100644
--- a/src/gui/text/qtexttable.cpp
+++ b/src/gui/text/qtexttable.cpp
@@ -824,7 +824,7 @@ void QTextTable::insertColumns(int pos, int num)
QVector<QTextLength> columnWidths = tfmt.columnWidthConstraints();
if (! columnWidths.isEmpty()) {
for (int i = num; i > 0; --i)
- columnWidths.insert(pos, columnWidths[qMax(0, pos-1)]);
+ columnWidths.insert(pos, columnWidths.at(qMax(0, pos - 1)));
}
tfmt.setColumnWidthConstraints (columnWidths);
QTextObject::setFormat(tfmt);
@@ -1046,11 +1046,12 @@ void QTextTable::mergeCells(int row, int column, int numRows, int numCols)
// find the position at which to insert the contents of the merged cells
QFragmentFindHelper helper(origCellPosition, p->fragmentMap());
- const auto it = std::lower_bound(d->cells.begin(), d->cells.end(), helper);
+ const auto begin = d->cells.cbegin();
+ const auto it = std::lower_bound(begin, d->cells.cend(), helper);
Q_ASSERT(it != d->cells.end());
Q_ASSERT(!(helper < *it));
Q_ASSERT(*it == cellFragment);
- const int insertCellIndex = it - d->cells.begin();
+ const int insertCellIndex = it - begin;
int insertFragment = d->cells.value(insertCellIndex + 1, d->fragment_end);
uint insertPos = p->fragmentMap().position(insertFragment);
@@ -1079,11 +1080,12 @@ void QTextTable::mergeCells(int row, int column, int numRows, int numCols)
if (firstCellIndex == -1) {
QFragmentFindHelper helper(pos, p->fragmentMap());
- const auto it = std::lower_bound(d->cells.begin(), d->cells.end(), helper);
+ const auto begin = d->cells.cbegin();
+ const auto it = std::lower_bound(begin, d->cells.cend(), helper);
Q_ASSERT(it != d->cells.end());
Q_ASSERT(!(helper < *it));
Q_ASSERT(*it == fragment);
- firstCellIndex = cellIndex = it - d->cells.begin();
+ firstCellIndex = cellIndex = it - begin;
}
++cellIndex;
@@ -1136,7 +1138,7 @@ void QTextTable::mergeCells(int row, int column, int numRows, int numCols)
}
}
- d->fragment_start = d->cells.first();
+ d->fragment_start = d->cells.constFirst();
fmt.setTableCellRowSpan(numRows);
fmt.setTableCellColumnSpan(numCols);
@@ -1212,9 +1214,9 @@ void QTextTable::splitCell(int row, int column, int numRows, int numCols)
for (int r = row + 1; r < row + rowSpan; ++r) {
// find the cell before which to insert the new cell markers
int gridIndex = r * d->nCols + column;
- QVector<int>::iterator it = std::upper_bound(d->cellIndices.begin(), d->cellIndices.end(), gridIndex);
- int cellIndex = it - d->cellIndices.begin();
- int fragment = d->cells.value(cellIndex, d->fragment_end);
+ const auto begin = d->cellIndices.cbegin();
+ const auto it = std::upper_bound(begin, d->cellIndices.cend(), gridIndex);
+ int fragment = d->cells.value(it - begin, d->fragment_end);
rowPositions[r - row] = p->fragmentMap().position(fragment);
}
diff --git a/src/gui/util/qgridlayoutengine.cpp b/src/gui/util/qgridlayoutengine.cpp
index 20bc7166ab..8ff2a3eeec 100644
--- a/src/gui/util/qgridlayoutengine.cpp
+++ b/src/gui/util/qgridlayoutengine.cpp
@@ -218,8 +218,9 @@ void QGridLayoutRowData::calculateGeometries(int start, int end, qreal targetSiz
qreal sumAvailable;
for (int i = 0; i < n; ++i) {
- if (stretches[start + i] > 0)
- sumStretches += stretches[start + i];
+ const int stretch = stretches.at(start + i);
+ if (stretch > 0)
+ sumStretches += stretch;
}
if (targetSize < totalBox.q_preferredSize) {
@@ -1034,19 +1035,19 @@ void QGridLayoutEngine::setGeometries(const QRectF &contentsGeometry, const QAbs
for (int i = q_items.count() - 1; i >= 0; --i) {
QGridLayoutItem *item = q_items.at(i);
- qreal x = q_xx[item->firstColumn()];
- qreal y = q_yy[item->firstRow()];
- qreal width = q_widths[item->lastColumn()];
- qreal height = q_heights[item->lastRow()];
+ qreal x = q_xx.at(item->firstColumn());
+ qreal y = q_yy.at(item->firstRow());
+ qreal width = q_widths.at(item->lastColumn());
+ qreal height = q_heights.at(item->lastRow());
if (item->columnSpan() != 1)
- width += q_xx[item->lastColumn()] - x;
+ width += q_xx.at(item->lastColumn()) - x;
if (item->rowSpan() != 1)
- height += q_yy[item->lastRow()] - y;
+ height += q_yy.at(item->lastRow()) - y;
const Qt::Alignment align = effectiveAlignment(item);
QRectF geom = item->geometryWithin(contentsGeometry.x() + x, contentsGeometry.y() + y,
- width, height, q_descents[item->lastRow()], align, m_snapToPixelGrid);
+ width, height, q_descents.at(item->lastRow()), align, m_snapToPixelGrid);
if (m_snapToPixelGrid) {
// x and y should already be rounded, but the call to geometryWithin() above might
// result in a geom with x,y at half-pixels (due to centering within the cell)