From b57d78d32238fc7f7dcccb02be29aa3df3da531e Mon Sep 17 00:00:00 2001 From: Albert Astals Cid Date: Fri, 4 Oct 2019 17:20:03 +0200 Subject: Minor performance improvements suggested by clang-tidy * Add const & to function parameters * Add const & to variables assigned from functions that return const & Change-Id: Ibf35e54ffb78f164493222125411f2ba279cb861 Reviewed-by: Mitch Curtis --- src/quickcontrols2/qquickattachedobject.cpp | 2 +- src/quickcontrols2/qquickiconlabel.cpp | 2 +- src/quickcontrols2/qquickiconlabel_p.h | 2 +- src/quickcontrols2/qquickstyle.cpp | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) (limited to 'src/quickcontrols2') diff --git a/src/quickcontrols2/qquickattachedobject.cpp b/src/quickcontrols2/qquickattachedobject.cpp index c43f7dc5..722f22f9 100644 --- a/src/quickcontrols2/qquickattachedobject.cpp +++ b/src/quickcontrols2/qquickattachedobject.cpp @@ -119,7 +119,7 @@ static QList findAttachedChildren(const QMetaObject *typ if (window) { item = window->contentItem(); - const auto windowChildren = window->children(); + const auto &windowChildren = window->children(); for (QObject *child : windowChildren) { QQuickWindow *childWindow = qobject_cast(child); if (childWindow) { diff --git a/src/quickcontrols2/qquickiconlabel.cpp b/src/quickcontrols2/qquickiconlabel.cpp index b246621b..536b3c1b 100644 --- a/src/quickcontrols2/qquickiconlabel.cpp +++ b/src/quickcontrols2/qquickiconlabel.cpp @@ -408,7 +408,7 @@ QString QQuickIconLabel::text() const return d->text; } -void QQuickIconLabel::setText(const QString text) +void QQuickIconLabel::setText(const QString &text) { Q_D(QQuickIconLabel); if (d->text == text) diff --git a/src/quickcontrols2/qquickiconlabel_p.h b/src/quickcontrols2/qquickiconlabel_p.h index df79dbf2..75b77064 100644 --- a/src/quickcontrols2/qquickiconlabel_p.h +++ b/src/quickcontrols2/qquickiconlabel_p.h @@ -88,7 +88,7 @@ public: void setIcon(const QQuickIcon &icon); QString text() const; - void setText(const QString text); + void setText(const QString &text); QFont font() const; void setFont(const QFont &font); diff --git a/src/quickcontrols2/qquickstyle.cpp b/src/quickcontrols2/qquickstyle.cpp index e2b6678b..408a0de3 100644 --- a/src/quickcontrols2/qquickstyle.cpp +++ b/src/quickcontrols2/qquickstyle.cpp @@ -495,7 +495,7 @@ static bool qt_is_dark_system_theme() { if (const QPlatformTheme *theme = QGuiApplicationPrivate::platformTheme()) { if (const QPalette *systemPalette = theme->palette(QPlatformTheme::SystemPalette)) { - const QColor textColor = systemPalette->color(QPalette::WindowText); + const QColor &textColor = systemPalette->color(QPalette::WindowText); return textColor.red() > 128 && textColor.blue() > 128 && textColor.green() > 128; } } -- cgit v1.2.3 From 072b5369ee107251d6800970263f573f74864fca Mon Sep 17 00:00:00 2001 From: Mitch Curtis Date: Wed, 16 Oct 2019 10:45:46 +0200 Subject: Adapt Tumbler after ListView changes After 2d9cf3ef, ListView now changes the currentIndex for some unknown reason. The changes clearly didn't cause any failures in Qt Quick's auto tests, but some Tumbler auto tests fail. Presumably, the failures are due to TumblerView's intimate usage of Qt Quick's C++ API, where it creates either a PathView or a ListView on demand internally. From what I could see, the currentIndex change was caused by this code: if (FxViewItem *snapItem = d->snapItemAt(d->highlight->position())) { if (snapItem->index >= 0 && snapItem->index != d->currentIndex) d->updateCurrent(snapItem->index); } So I worked around the issue by delaying the call to setHighlightRangeMode() until after the delegate has been created. I also tried moving the call to setSnapMode() (which seems very relevant given the context), but it caused test failures. Change-Id: I7017760c21193dc6ce8181669ba7cf047b18dfba Fixes: QTBUG-79150 Reviewed-by: Shawn Rutledge --- src/quickcontrols2/qquicktumblerview.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'src/quickcontrols2') diff --git a/src/quickcontrols2/qquicktumblerview.cpp b/src/quickcontrols2/qquicktumblerview.cpp index 5f5c065d..4a64ad7f 100644 --- a/src/quickcontrols2/qquicktumblerview.cpp +++ b/src/quickcontrols2/qquicktumblerview.cpp @@ -180,7 +180,6 @@ void QQuickTumblerView::createView() QQml_setParent_noEvent(m_listView, this); m_listView->setParentItem(this); m_listView->setSnapMode(QQuickListView::SnapToItem); - m_listView->setHighlightRangeMode(QQuickListView::StrictlyEnforceRange); m_listView->setClip(true); // Give the view a size. @@ -193,6 +192,8 @@ void QQuickTumblerView::createView() // the view animates any potential currentIndex change over one second, // which we don't want when the contentItem has just been created. m_listView->setDelegate(m_delegate); + // Set this after setting the delegate to avoid unexpected currentIndex changes: QTBUG-79150 + m_listView->setHighlightRangeMode(QQuickListView::StrictlyEnforceRange); m_listView->setHighlightMoveDuration(1000); qCDebug(lcTumblerView) << "finished creating ListView"; -- cgit v1.2.3