summaryrefslogtreecommitdiffstats
path: root/src/gui
diff options
context:
space:
mode:
authorLiang Qi <liang.qi@qt.io>2016-06-13 09:01:02 +0200
committerLiang Qi <liang.qi@qt.io>2016-06-13 12:46:46 +0200
commit511790fd1af1e2886a0e2e8dd4308099705cd815 (patch)
treeb42aee537a6103cd064f9f41ae2889b09b79fd23 /src/gui
parent1542d8881fc5ccbc5918cd4acbe4091ebbd24508 (diff)
parentcbe332405aa22257d432f1797b325f5e57007c20 (diff)
Merge remote-tracking branch 'origin/5.7' into dev
Conflicts: config_help.txt configure mkspecs/features/uikit/sdk.prf src/corelib/global/qhooks.cpp src/corelib/io/qfilesystemwatcher.cpp src/corelib/io/qlockfile_unix.cpp src/corelib/tools/qalgorithms.h src/gui/kernel/qwindowsysteminterface.h src/gui/text/qtextdocument_p.cpp src/network/access/access.pri src/network/access/qnetworkaccessmanager.cpp src/network/access/qnetworkreplynsurlconnectionimpl.mm src/src.pro src/testlib/qtestcase.cpp src/widgets/kernel/qwidgetbackingstore_p.h src/widgets/styles/qwindowscestyle.cpp src/widgets/styles/qwindowsmobilestyle.cpp tests/auto/corelib/io/qdiriterator/qdiriterator.pro tests/auto/corelib/io/qfileinfo/qfileinfo.pro tests/auto/gui/kernel/qwindow/BLACKLIST tests/auto/widgets/dialogs/qfilesystemmodel/tst_qfilesystemmodel.cpp tools/configure/configureapp.cpp Change-Id: Ibf7fb9c8cf263a810ade82f821345d0725c57c67
Diffstat (limited to 'src/gui')
-rw-r--r--src/gui/doc/snippets/code/src_gui_kernel_qclipboard.cpp2
-rw-r--r--src/gui/image/qbmphandler.cpp16
-rw-r--r--src/gui/image/qicon.cpp2
-rw-r--r--src/gui/image/qiconloader.cpp2
-rw-r--r--src/gui/image/qimage.cpp55
-rw-r--r--src/gui/image/qimagepixmapcleanuphooks.cpp18
-rw-r--r--src/gui/image/qpnghandler.cpp2
-rw-r--r--src/gui/image/qxpmhandler.cpp2
-rw-r--r--src/gui/itemmodels/qstandarditemmodel.cpp9
-rw-r--r--src/gui/kernel/qclipboard.cpp8
-rw-r--r--src/gui/kernel/qevent.cpp3
-rw-r--r--src/gui/kernel/qguiapplication.cpp4
-rw-r--r--src/gui/kernel/qkeysequence.cpp13
-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/kernel/qwindowsysteminterface.h4
-rw-r--r--src/gui/opengl/qopenglframebufferobject.cpp7
-rw-r--r--src/gui/opengl/qopenglgradientcache.cpp33
-rw-r--r--src/gui/painting/qpainter.cpp11
-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.cpp10
-rw-r--r--src/gui/text/qfont.cpp4
-rw-r--r--src/gui/text/qfontdatabase.cpp17
-rw-r--r--src/gui/text/qfontengine.cpp3
-rw-r--r--src/gui/text/qfragmentmap_p.h9
-rw-r--r--src/gui/text/qtextdocument.cpp15
-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.cpp12
-rw-r--r--src/gui/text/qtextformat.cpp9
-rw-r--r--src/gui/text/qtextformat.h4
-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
40 files changed, 224 insertions, 219 deletions
diff --git a/src/gui/doc/snippets/code/src_gui_kernel_qclipboard.cpp b/src/gui/doc/snippets/code/src_gui_kernel_qclipboard.cpp
index d5f610cf28..8581510133 100644
--- a/src/gui/doc/snippets/code/src_gui_kernel_qclipboard.cpp
+++ b/src/gui/doc/snippets/code/src_gui_kernel_qclipboard.cpp
@@ -49,7 +49,7 @@
****************************************************************************/
//! [0]
-QClipboard *clipboard = QApplication::clipboard();
+QClipboard *clipboard = QGuiApplication::clipboard();
QString originalText = clipboard->text();
...
clipboard->setText(newText);
diff --git a/src/gui/image/qbmphandler.cpp b/src/gui/image/qbmphandler.cpp
index b8290861af..9545abfd21 100644
--- a/src/gui/image/qbmphandler.cpp
+++ b/src/gui/image/qbmphandler.cpp
@@ -289,6 +289,12 @@ static bool read_dib_body(QDataStream &s, const BMP_INFOHDR &bi, int offset, int
format = QImage::Format_Mono;
}
+ if (depth != 32) {
+ ncols = bi.biClrUsed ? bi.biClrUsed : 1 << nbits;
+ if (ncols < 1 || ncols > 256) // sanity check - don't run out of mem if color table is broken
+ return false;
+ }
+
if (bi.biHeight < 0)
h = -h; // support images with negative height
@@ -296,19 +302,15 @@ static bool read_dib_body(QDataStream &s, const BMP_INFOHDR &bi, int offset, int
image = QImage(w, h, format);
if (image.isNull()) // could not create image
return false;
- }
-
- if (depth != 32) {
- ncols = bi.biClrUsed ? bi.biClrUsed : 1 << nbits;
- if (ncols < 1 || ncols > 256) // sanity check - don't run out of mem if color table is broken
- return false;
- image.setColorCount(ncols);
+ if (ncols)
+ image.setColorCount(ncols); // Ensure valid QImage
}
image.setDotsPerMeterX(bi.biXPelsPerMeter);
image.setDotsPerMeterY(bi.biYPelsPerMeter);
if (ncols > 0) { // read color table
+ image.setColorCount(ncols);
uchar rgb[4];
int rgb_len = t == BMP_OLD ? 3 : 4;
for (int i=0; i<ncols; i++) {
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 cc8337fcb9..38782ac0a0 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/qimage.cpp b/src/gui/image/qimage.cpp
index 3238d83729..3a31af8645 100644
--- a/src/gui/image/qimage.cpp
+++ b/src/gui/image/qimage.cpp
@@ -176,6 +176,9 @@ QImageData::~QImageData()
data = 0;
}
+#if defined(_M_ARM)
+#pragma optimize("", off)
+#endif
bool QImageData::checkForAlphaPixels() const
{
@@ -193,74 +196,81 @@ bool QImageData::checkForAlphaPixels() const
break;
case QImage::Format_ARGB32:
case QImage::Format_ARGB32_Premultiplied: {
- uchar *bits = data;
+ const uchar *bits = data;
for (int y=0; y<height && !has_alpha_pixels; ++y) {
+ uint alphaAnd = 0xff000000;
for (int x=0; x<width; ++x)
- has_alpha_pixels |= (((uint *)bits)[x] & 0xff000000) != 0xff000000;
+ alphaAnd &= reinterpret_cast<const uint*>(bits)[x];
+ has_alpha_pixels = (alphaAnd != 0xff000000);
bits += bytes_per_line;
}
} break;
case QImage::Format_RGBA8888:
case QImage::Format_RGBA8888_Premultiplied: {
- uchar *bits = data;
+ const uchar *bits = data;
for (int y=0; y<height && !has_alpha_pixels; ++y) {
+ uchar alphaAnd = 0xff;
for (int x=0; x<width; ++x)
- has_alpha_pixels |= bits[x*4+3] != 0xff;
+ alphaAnd &= bits[x * 4+ 3];
+ has_alpha_pixels = (alphaAnd != 0xff);
bits += bytes_per_line;
}
} break;
case QImage::Format_A2BGR30_Premultiplied:
case QImage::Format_A2RGB30_Premultiplied: {
- uchar *bits = data;
+ const uchar *bits = data;
for (int y=0; y<height && !has_alpha_pixels; ++y) {
+ uint alphaAnd = 0xc0000000;
for (int x=0; x<width; ++x)
- has_alpha_pixels |= (((uint *)bits)[x] & 0xc0000000) != 0xc0000000;
+ alphaAnd &= reinterpret_cast<const uint*>(bits)[x];
+ has_alpha_pixels = (alphaAnd != 0xc0000000);
bits += bytes_per_line;
}
} break;
case QImage::Format_ARGB8555_Premultiplied:
case QImage::Format_ARGB8565_Premultiplied: {
- uchar *bits = data;
- uchar *end_bits = data + bytes_per_line;
+ const uchar *bits = data;
+ const uchar *end_bits = data + bytes_per_line;
for (int y=0; y<height && !has_alpha_pixels; ++y) {
+ uchar alphaAnd = 0xff;
while (bits < end_bits) {
- has_alpha_pixels |= bits[0] != 0;
+ alphaAnd &= bits[0];
bits += 3;
}
+ has_alpha_pixels = (alphaAnd != 0xff);
bits = end_bits;
end_bits += bytes_per_line;
}
} break;
case QImage::Format_ARGB6666_Premultiplied: {
- uchar *bits = data;
- uchar *end_bits = data + bytes_per_line;
+ const uchar *bits = data;
+ const uchar *end_bits = data + bytes_per_line;
for (int y=0; y<height && !has_alpha_pixels; ++y) {
+ uchar alphaAnd = 0xfc;
while (bits < end_bits) {
- has_alpha_pixels |= (bits[0] & 0xfc) != 0;
+ alphaAnd &= bits[0];
bits += 3;
}
+ has_alpha_pixels = (alphaAnd != 0xfc);
bits = end_bits;
end_bits += bytes_per_line;
}
} break;
case QImage::Format_ARGB4444_Premultiplied: {
- uchar *bits = data;
- uchar *end_bits = data + bytes_per_line;
-
+ const uchar *bits = data;
for (int y=0; y<height && !has_alpha_pixels; ++y) {
- while (bits < end_bits) {
- has_alpha_pixels |= (bits[0] & 0xf0) != 0;
- bits += 2;
- }
- bits = end_bits;
- end_bits += bytes_per_line;
+ ushort alphaAnd = 0xf000;
+ for (int x=0; x<width; ++x)
+ alphaAnd &= reinterpret_cast<const ushort*>(bits)[x];
+ has_alpha_pixels = (alphaAnd != 0xf000);
+ bits += bytes_per_line;
}
} break;
@@ -283,6 +293,9 @@ bool QImageData::checkForAlphaPixels() const
return has_alpha_pixels;
}
+#if defined(_M_ARM)
+#pragma optimize("", on)
+#endif
/*!
\class QImage
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/qpnghandler.cpp b/src/gui/image/qpnghandler.cpp
index 7fbb498bbb..96d6be502d 100644
--- a/src/gui/image/qpnghandler.cpp
+++ b/src/gui/image/qpnghandler.cpp
@@ -749,7 +749,7 @@ static void set_text(const QImage &image, png_structp png_ptr, png_infop info_pt
QMap<QString, QString>::ConstIterator it = text.constBegin();
int i = 0;
while (it != text.constEnd()) {
- text_ptr[i].key = qstrdup(it.key().left(79).toLatin1().constData());
+ text_ptr[i].key = qstrdup(it.key().leftRef(79).toLatin1().constData());
bool noCompress = (it.value().length() < 40);
#ifdef PNG_iTXt_SUPPORTED
diff --git a/src/gui/image/qxpmhandler.cpp b/src/gui/image/qxpmhandler.cpp
index 5c8ff84929..756e31318f 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 ff54602a5d..973e5c4333 100644
--- a/src/gui/itemmodels/qstandarditemmodel.cpp
+++ b/src/gui/itemmodels/qstandarditemmodel.cpp
@@ -3018,10 +3018,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);
}
}
@@ -3130,13 +3127,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/qclipboard.cpp b/src/gui/kernel/qclipboard.cpp
index 7932b9a2dc..e9da36a42a 100644
--- a/src/gui/kernel/qclipboard.cpp
+++ b/src/gui/kernel/qclipboard.cpp
@@ -67,7 +67,7 @@ QT_BEGIN_NAMESPACE
Drop}.
There is a single QClipboard object in an application, accessible
- as QApplication::clipboard().
+ as QGuiApplication::clipboard().
Example:
\snippet code/src_gui_kernel_qclipboard.cpp 0
@@ -137,7 +137,7 @@ QT_BEGIN_NAMESPACE
\endlist
- \sa QApplication
+ \sa QGuiApplication
*/
/*!
@@ -147,7 +147,7 @@ QT_BEGIN_NAMESPACE
Do not call this function.
- Call QApplication::clipboard() instead to get a pointer to the
+ Call QGuiApplication::clipboard() instead to get a pointer to the
application's global clipboard object.
There is only one clipboard in the window system, and creating
@@ -165,7 +165,7 @@ QClipboard::QClipboard(QObject *parent)
Destroys the clipboard.
- You should never delete the clipboard. QApplication will do this
+ You should never delete the clipboard. QGuiApplication will do this
when the application terminates.
*/
QClipboard::~QClipboard()
diff --git a/src/gui/kernel/qevent.cpp b/src/gui/kernel/qevent.cpp
index 305ce5c82e..6adbea6da6 100644
--- a/src/gui/kernel/qevent.cpp
+++ b/src/gui/kernel/qevent.cpp
@@ -3904,6 +3904,9 @@ QDebug operator<<(QDebug dbg, const QEvent *e)
case QEvent::Expose:
dbg << "QExposeEvent(" << static_cast<const QExposeEvent *>(e)->region() << ')';
break;
+ case QEvent::Paint:
+ dbg << "QPaintEvent(" << static_cast<const QPaintEvent *>(e)->region() << ')';
+ break;
case QEvent::MouseButtonPress:
case QEvent::MouseMove:
case QEvent::MouseButtonRelease:
diff --git a/src/gui/kernel/qguiapplication.cpp b/src/gui/kernel/qguiapplication.cpp
index d0bfc7ff5f..7afeadcced 100644
--- a/src/gui/kernel/qguiapplication.cpp
+++ b/src/gui/kernel/qguiapplication.cpp
@@ -1035,7 +1035,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;
@@ -2641,7 +2641,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..e7b1f9e073 100644
--- a/src/gui/kernel/qkeysequence.cpp
+++ b/src/gui/kernel/qkeysequence.cpp
@@ -1154,21 +1154,22 @@ int QKeySequencePrivate::decodeString(const QString &str, QKeySequence::Sequence
}
int p = accel.lastIndexOf(QLatin1Char('+'), str.length() - 2); // -2 so that Ctrl++ works
+ QStringRef accelRef(&accel);
if(p > 0)
- accel = accel.mid(p + 1);
+ accelRef = accelRef.mid(p + 1);
int fnum = 0;
- if (accel.length() == 1) {
+ if (accelRef.length() == 1) {
#if defined(Q_OS_MACX)
- int qtKey = qtkeyForMacSymbol(accel[0]);
+ int qtKey = qtkeyForMacSymbol(accelRef.at(0));
if (qtKey != -1) {
ret |= qtKey;
} else
#endif
{
- ret |= accel[0].toUpper().unicode();
+ ret |= accelRef.at(0).toUpper().unicode();
}
- } else if (accel[0] == QLatin1Char('f') && (fnum = accel.mid(1).toInt()) && (fnum >= 1) && (fnum <= 35)) {
+ } else if (accelRef.at(0) == QLatin1Char('f') && (fnum = accelRef.mid(1).toInt()) >= 1 && fnum <= 35) {
ret |= Qt::Key_F1 + fnum - 1;
} else {
// For NativeText, check the traslation table first,
@@ -1182,7 +1183,7 @@ int QKeySequencePrivate::decodeString(const QString &str, QKeySequence::Sequence
QString keyName(tran == 0
? QCoreApplication::translate("QShortcut", keyname[i].name)
: QString::fromLatin1(keyname[i].name));
- if (accel == keyName.toLower()) {
+ if (accelRef == keyName.toLower()) {
ret |= keyname[i].key;
found = true;
break;
diff --git a/src/gui/kernel/qopenglcontext.cpp b/src/gui/kernel/qopenglcontext.cpp
index 19464eeca3..7e5697e5d8 100644
--- a/src/gui/kernel/qopenglcontext.cpp
+++ b/src/gui/kernel/qopenglcontext.cpp
@@ -1418,7 +1418,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();
@@ -1582,7 +1582,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/kernel/qwindowsysteminterface.h b/src/gui/kernel/qwindowsysteminterface.h
index cde70a1102..5e42f5ba90 100644
--- a/src/gui/kernel/qwindowsysteminterface.h
+++ b/src/gui/kernel/qwindowsysteminterface.h
@@ -117,7 +117,7 @@ public:
static void handleWheelEvent(QWindow *w, ulong timestamp, const QPointF & local, const QPointF & global, int d, Qt::Orientation o, Qt::KeyboardModifiers mods = Qt::NoModifier);
struct TouchPoint {
- TouchPoint() : id(0), uniqueId(-1), pressure(0), rotation(0), state(Qt::TouchPointStationary), flags(0) { }
+ TouchPoint() : id(0), uniqueId(-1), pressure(0), rotation(0), state(Qt::TouchPointStationary) { }
int id; // for application use
qint64 uniqueId; // for TUIO: object/token ID; otherwise empty
// TODO for TUIO 2.0: add registerPointerUniqueID(QPointerUniqueId)
@@ -142,7 +142,7 @@ public:
// rect is relative to parent
static void handleGeometryChange(QWindow *w, const QRect &newRect, const QRect &oldRect = QRect());
- static void handleCloseEvent(QWindow *w, bool *accepted = 0);
+ static void handleCloseEvent(QWindow *w, bool *accepted = Q_NULLPTR);
static void handleEnterEvent(QWindow *w, const QPointF &local = QPointF(), const QPointF& global = QPointF());
static void handleLeaveEvent(QWindow *w);
static void handleEnterLeaveEvent(QWindow *enter, QWindow *leave, const QPointF &local = QPointF(), const QPointF& global = QPointF());
diff --git a/src/gui/opengl/qopenglframebufferobject.cpp b/src/gui/opengl/qopenglframebufferobject.cpp
index b932ee60c9..303d4d4eb1 100644
--- a/src/gui/opengl/qopenglframebufferobject.cpp
+++ b/src/gui/opengl/qopenglframebufferobject.cpp
@@ -1073,7 +1073,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);
}
}
@@ -1206,10 +1206,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 8defcfb28d..6472481e7a 100644
--- a/src/gui/painting/qpainter.cpp
+++ b/src/gui/painting/qpainter.cpp
@@ -2186,11 +2186,10 @@ void QPainter::setBrushOrigin(const QPointF &p)
destination pixel in such a way that the alpha component of the
source defines the translucency of the pixel.
- When the paint device is a QImage, the image format must be set to
- \l {QImage::Format}{Format_ARGB32_Premultiplied} or
- \l {QImage::Format}{Format_ARGB32} for the composition modes to have
- any effect. For performance the premultiplied version is the preferred
- format.
+ Several composition modes require an alpha channel in the source or
+ target images to have an effect. For optimal performance the
+ image format \l {QImage::Format}{Format_ARGB32_Premultiplied} is
+ preferred.
When a composition mode is set it applies to all painting
operator, pens, brushes, gradients and pixmap/image drawing.
@@ -2469,7 +2468,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 7072a2d79c..7dbc83b338 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;
}
@@ -1685,8 +1685,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;
}
@@ -1708,7 +1709,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) {
@@ -1717,7 +1718,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;
}
@@ -2789,7 +2790,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 b014305796..34f1c51f6d 100644
--- a/src/gui/painting/qpdf.cpp
+++ b/src/gui/painting/qpdf.cpp
@@ -1674,7 +1674,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"
@@ -1767,7 +1767,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 bb92e6bfba..940de87eee 100644
--- a/src/gui/text/qcssparser.cpp
+++ b/src/gui/text/qcssparser.cpp
@@ -1507,10 +1507,10 @@ 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);
+ const auto args = func[1].splitRef(QLatin1Char(' '), QString::SkipEmptyParts);
if (args.count() != 4)
return QRect();
QRect rect(args[0].toInt(), args[1].toInt(), args[2].toInt(), args[3].toInt());
@@ -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;
@@ -1914,9 +1915,8 @@ bool StyleSelector::basicSelectorMatches(const BasicSelector &sel, NodePtr node)
return false;
if (a.valueMatchCriterium == QCss::AttributeSelector::MatchContains) {
-
- QStringList lst = attrValue.split(QLatin1Char(' '));
- if (!lst.contains(a.value))
+ const auto lst = attrValue.splitRef(QLatin1Char(' '));
+ if (!lst.contains(QStringRef(&a.value)))
return false;
} else if (
(a.valueMatchCriterium == QCss::AttributeSelector::MatchEqual
diff --git a/src/gui/text/qfont.cpp b/src/gui/text/qfont.cpp
index f92e4ab457..828dbc318c 100644
--- a/src/gui/text/qfont.cpp
+++ b/src/gui/text/qfont.cpp
@@ -2033,7 +2033,7 @@ uint qHash(const QFont &font, uint seed) Q_DECL_NOTHROW
*/
bool QFont::fromString(const QString &descrip)
{
- QStringList l(descrip.split(QLatin1Char(',')));
+ const auto l = descrip.splitRef(QLatin1Char(','));
int count = l.count();
if (!count || (count > 2 && count < 9) || count > 11) {
@@ -2042,7 +2042,7 @@ bool QFont::fromString(const QString &descrip)
return false;
}
- setFamily(l[0]);
+ setFamily(l[0].toString());
if (count > 1 && l[1].toDouble() > 0.0)
setPointSizeF(l[1].toDouble());
if (count == 9) {
diff --git a/src/gui/text/qfontdatabase.cpp b/src/gui/text/qfontdatabase.cpp
index e4c9b45dc2..cdfcdec80c 100644
--- a/src/gui/text/qfontdatabase.cpp
+++ b/src/gui/text/qfontdatabase.cpp
@@ -697,25 +697,20 @@ static QStringList familyList(const QFontDef &req)
if (req.family.isEmpty())
return family_list;
- QStringList list = req.family.split(QLatin1Char(','));
+ const auto list = req.family.splitRef(QLatin1Char(','));
const int numFamilies = list.size();
family_list.reserve(numFamilies);
for (int i = 0; i < numFamilies; ++i) {
- QString str = list.at(i).trimmed();
+ QStringRef str = list.at(i).trimmed();
if ((str.startsWith(QLatin1Char('"')) && str.endsWith(QLatin1Char('"')))
|| (str.startsWith(QLatin1Char('\'')) && str.endsWith(QLatin1Char('\''))))
str = str.mid(1, str.length() - 2);
- family_list << str;
+ family_list << str.toString();
}
// append the substitute list for each family in family_list
- QStringList subs_list;
- QStringList::ConstIterator it = family_list.constBegin(), end = family_list.constEnd();
- for (; it != end; ++it)
- subs_list += QFont::substitutes(*it);
-// qDebug() << "adding substs: " << subs_list;
-
- family_list += subs_list;
+ for (int i = 0, size = family_list.size(); i < size; ++i)
+ family_list += QFont::substitutes(family_list.at(i));
return family_list;
}
@@ -2737,8 +2732,6 @@ void QFontDatabase::load(const QFontPrivate *d, int script)
}
if (req.pointSize < 0)
req.pointSize = req.pixelSize*72.0/d->dpi;
- if (req.weight == 0)
- req.weight = QFont::Normal;
if (req.stretch == 0)
req.stretch = 100;
diff --git a/src/gui/text/qfontengine.cpp b/src/gui/text/qfontengine.cpp
index 16c654dcb7..adc8f634dc 100644
--- a/src/gui/text/qfontengine.cpp
+++ b/src/gui/text/qfontengine.cpp
@@ -1833,8 +1833,7 @@ QFontEngine *QFontEngineMulti::loadEngine(int at)
request.family = fallbackFamilyAt(at - 1);
if (QFontEngine *engine = QFontDatabase::findFont(request, m_script)) {
- if (request.weight > QFont::Normal)
- engine->fontDef.weight = request.weight;
+ engine->fontDef.weight = request.weight;
if (request.style > QFont::StyleNormal)
engine->fontDef.style = request.style;
return engine;
diff --git a/src/gui/text/qfragmentmap_p.h b/src/gui/text/qfragmentmap_p.h
index 4cf17aadc7..b54d7261d0 100644
--- a/src/gui/text/qfragmentmap_p.h
+++ b/src/gui/text/qfragmentmap_p.h
@@ -255,14 +255,11 @@ uint QFragmentMapData<Fragment>::createFragment()
uint freePos = head->freelist;
if (freePos == head->allocated) {
// need to create some free space
- if (freePos >= uint(MaxAllocSize) / fragmentSize)
- qBadAlloc();
- uint needed = qAllocMore((freePos+1)*fragmentSize, 0);
- Q_ASSERT(needed/fragmentSize > head->allocated);
- Fragment *newFragments = (Fragment *)realloc(fragments, needed);
+ auto blockInfo = qCalculateGrowingBlockSize(freePos + 1, fragmentSize);
+ Fragment *newFragments = (Fragment *)realloc(fragments, blockInfo.size);
Q_CHECK_PTR(newFragments);
fragments = newFragments;
- head->allocated = needed/fragmentSize;
+ head->allocated = quint32(blockInfo.elementCount);
F(freePos).right = 0;
}
diff --git a/src/gui/text/qtextdocument.cpp b/src/gui/text/qtextdocument.cpp
index 8e4fa8a730..a3dbf455cf 100644
--- a/src/gui/text/qtextdocument.cpp
+++ b/src/gui/text/qtextdocument.cpp
@@ -2430,7 +2430,7 @@ bool QTextHtmlExporter::emitCharFormatStyle(const QTextCharFormat &format)
html += QLatin1Char(';');
attributesEmitted = true;
} else {
- html.chop(qstrlen(decorationTag.latin1()));
+ html.chop(decorationTag.size());
}
if (format.foreground() != defaultCharFormat.foreground()
@@ -2665,7 +2665,7 @@ void QTextHtmlExporter::emitFragment(const QTextFragment &fragment)
if (attributesEmitted)
html += QLatin1String("\">");
else
- html.chop(qstrlen(styleTag.latin1()));
+ html.chop(styleTag.size());
if (isObject) {
for (int i = 0; isImage && i < txt.length(); ++i) {
@@ -2700,13 +2700,8 @@ void QTextHtmlExporter::emitFragment(const QTextFragment &fragment)
// split for [\n{LineSeparator}]
QString forcedLineBreakRegExp = QString::fromLatin1("[\\na]");
forcedLineBreakRegExp[3] = QChar::LineSeparator;
-
- const QStringList lines = txt.split(QRegExp(forcedLineBreakRegExp));
- for (int i = 0; i < lines.count(); ++i) {
- if (i > 0)
- html += QLatin1String("<br />"); // space on purpose for compatibility with Netscape, Lynx & Co.
- html += lines.at(i);
- }
+ // space in BR on purpose for compatibility with old-fashioned browsers
+ html += txt.replace(QRegExp(forcedLineBreakRegExp), QLatin1String("<br />"));
}
if (attributesEmitted)
@@ -3227,7 +3222,7 @@ void QTextHtmlExporter::emitFrameStyle(const QTextFrameFormat &format, FrameType
QString::number(format.rightMargin()));
if (html.length() == originalHtmlLength) // nothing emitted?
- html.chop(qstrlen(styleAttribute.latin1()));
+ html.chop(styleAttribute.size());
else
html += QLatin1Char('\"');
}
diff --git a/src/gui/text/qtextdocument_p.cpp b/src/gui/text/qtextdocument_p.cpp
index df0d52d8e9..3537adba9e 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,13 +1074,14 @@ 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
|| (c.command == QTextUndoCommand::Inserted && last.command == c.command && (last.block_part && !c.block_part))) {
// two sequential inserts that are not part of the same block => can merge
- if (last.tryMerge(c))
+ if (undoStack[lastIdx].tryMerge(c))
return;
}
}
@@ -1102,7 +1103,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;
}
@@ -1114,7 +1115,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;
}
@@ -1124,7 +1125,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;
}
@@ -1187,8 +1188,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 1b2113d281..0c8904b4c5 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 6be84c0186..d11f8c34b1 100644
--- a/src/gui/text/qtextengine.cpp
+++ b/src/gui/text/qtextengine.cpp
@@ -1643,8 +1643,14 @@ void QTextEngine::itemize() const
if (analysis->bidiLevel % 2)
--analysis->bidiLevel;
analysis->flags = QScriptAnalysis::LineOrParagraphSeparator;
- if (option.flags() & QTextOption::ShowLineAndParagraphSeparators)
+ if (option.flags() & QTextOption::ShowLineAndParagraphSeparators) {
+ const int offset = uc - string;
+ layoutData->string.detach();
+ string = reinterpret_cast<const ushort *>(layoutData->string.unicode());
+ uc = string + offset;
+ e = uc + length;
*const_cast<ushort*>(uc) = 0x21B5; // visual line separator
+ }
break;
case QChar::Tabulation:
analysis->flags = QScriptAnalysis::Tab;
@@ -3272,7 +3278,7 @@ int QTextEngine::endOfLine(int lineNum)
insertionPointsForLine(lineNum, insertionPoints);
if (insertionPoints.size() > 0)
- return insertionPoints.last();
+ return insertionPoints.constLast();
return 0;
}
@@ -3282,7 +3288,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..2109b15a85 100644
--- a/src/gui/text/qtextformat.cpp
+++ b/src/gui/text/qtextformat.cpp
@@ -364,9 +364,10 @@ void QTextFormatPrivate::recalcFont() const
f.setPixelSize(props.at(i).value.toInt());
break;
case QTextFormat::FontWeight: {
- int weight = props.at(i).value.toInt();
- if (weight == 0) weight = QFont::Normal;
- f.setWeight(weight);
+ const QVariant weightValue = props.at(i).value;
+ int weight = weightValue.toInt();
+ if (weight >= 0 && weightValue.isValid())
+ f.setWeight(weight);
break; }
case QTextFormat::FontItalic:
f.setItalic(props.at(i).value.toBool());
@@ -3462,7 +3463,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/qtextformat.h b/src/gui/text/qtextformat.h
index bc627521ff..805affd87c 100644
--- a/src/gui/text/qtextformat.h
+++ b/src/gui/text/qtextformat.h
@@ -431,9 +431,9 @@ public:
{ return doubleProperty(FontPointSize); }
inline void setFontWeight(int weight)
- { if (weight == QFont::Normal) weight = 0; setProperty(FontWeight, weight); }
+ { setProperty(FontWeight, weight); }
inline int fontWeight() const
- { int weight = intProperty(FontWeight); if (weight == 0) weight = QFont::Normal; return weight; }
+ { return hasProperty(FontWeight) ? intProperty(FontWeight) : QFont::Normal; }
inline void setFontItalic(bool italic)
{ setProperty(FontItalic, italic); }
inline bool fontItalic() const
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 f7741bad2c..73d2e545ba 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)