summaryrefslogtreecommitdiffstats
path: root/src/gui/kernel
diff options
context:
space:
mode:
authorAnton Kudryavtsev <a.kudryavtsev@netris.ru>2016-04-14 14:55:44 +0300
committerAnton Kudryavtsev <a.kudryavtsev@netris.ru>2016-06-01 09:35:29 +0000
commita24b90a21c4f2feb61630ca6a1684312556a6bc7 (patch)
tree1717ed9f699dd5cb119471ccb51f661b7d207f8b /src/gui/kernel
parentd11abc8bd7ac10da4bfd548b3d1d9d4e0dd6a264 (diff)
Gui: use const (and const APIs) more
For CoW types, prefer const methods to avoid needless detach()ing. Change-Id: I88d08d499e1be72c1f6d983fecdcee513df18aa2 Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
Diffstat (limited to 'src/gui/kernel')
-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
6 files changed, 13 insertions, 15 deletions
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;