summaryrefslogtreecommitdiffstats
path: root/src/widgets
diff options
context:
space:
mode:
authorLiang Qi <liang.qi@qt.io>2016-07-01 12:33:16 +0200
committerLiang Qi <liang.qi@qt.io>2016-07-01 13:21:29 +0200
commit200fdd96f0aae9d2060cf3b8cb491eda10d6d68f (patch)
tree80b3a1450c3fa8cbd44e07d82f6f5d3985a5902e /src/widgets
parentcb260c6c7f1ebd4b3fa5f86c3d98ec8ff0486095 (diff)
parente2665600c09358854bb0b29389cc873a2684f77b (diff)
Merge remote-tracking branch 'origin/5.7' into dev
Conflicts: configure configure.json Change-Id: Iba032d9a29c273da2585632bc6e22bbafb961808
Diffstat (limited to 'src/widgets')
-rw-r--r--src/widgets/itemviews/qabstractitemview.cpp11
-rw-r--r--src/widgets/itemviews/qabstractitemview_p.h3
-rw-r--r--src/widgets/kernel/qwidget.cpp1
-rw-r--r--src/widgets/kernel/qwidget_p.h1
-rw-r--r--src/widgets/kernel/qwidgetbackingstore.cpp18
-rw-r--r--src/widgets/widgets/qabstractspinbox.cpp4
-rw-r--r--src/widgets/widgets/qdockarealayout.cpp3
-rw-r--r--src/widgets/widgets/qdockwidget.cpp5
-rw-r--r--src/widgets/widgets/qtabbar.cpp6
-rw-r--r--src/widgets/widgets/qtextbrowser.cpp2
10 files changed, 34 insertions, 20 deletions
diff --git a/src/widgets/itemviews/qabstractitemview.cpp b/src/widgets/itemviews/qabstractitemview.cpp
index 42e0cc7585..4768c58d1d 100644
--- a/src/widgets/itemviews/qabstractitemview.cpp
+++ b/src/widgets/itemviews/qabstractitemview.cpp
@@ -2604,12 +2604,11 @@ QModelIndexList QAbstractItemView::selectedIndexes() const
QModelIndexList indexes;
if (d->selectionModel) {
indexes = d->selectionModel->selectedIndexes();
- QList<QModelIndex>::iterator it = indexes.begin();
- while (it != indexes.end())
- if (isIndexHidden(*it))
- it = indexes.erase(it);
- else
- ++it;
+ auto isHidden = [this](const QModelIndex &idx) {
+ return isIndexHidden(idx);
+ };
+ const auto end = indexes.end();
+ indexes.erase(std::remove_if(indexes.begin(), end, isHidden), end);
}
return indexes;
}
diff --git a/src/widgets/itemviews/qabstractitemview_p.h b/src/widgets/itemviews/qabstractitemview_p.h
index a3af79abcb..60ae1559b1 100644
--- a/src/widgets/itemviews/qabstractitemview_p.h
+++ b/src/widgets/itemviews/qabstractitemview_p.h
@@ -277,7 +277,8 @@ public:
const QEditorInfo &editorForIndex(const QModelIndex &index) const;
inline bool hasEditor(const QModelIndex &index) const {
- return indexEditorHash.find(index) != indexEditorHash.constEnd();
+ // Search's implicit cast (QModelIndex to QPersistentModelIndex) is slow; use cheap pre-test to avoid when we can.
+ return !indexEditorHash.isEmpty() && indexEditorHash.contains(index);
}
QModelIndex indexForEditor(QWidget *editor) const;
diff --git a/src/widgets/kernel/qwidget.cpp b/src/widgets/kernel/qwidget.cpp
index 6fa74b7cc6..a71089793c 100644
--- a/src/widgets/kernel/qwidget.cpp
+++ b/src/widgets/kernel/qwidget.cpp
@@ -281,6 +281,7 @@ QWidgetPrivate::QWidgetPrivate(int version)
#endif
#ifndef QT_NO_OPENGL
, renderToTextureReallyDirty(1)
+ , renderToTextureComposeActive(0)
#endif
#if defined(Q_OS_WIN)
, noPaintOnScreen(0)
diff --git a/src/widgets/kernel/qwidget_p.h b/src/widgets/kernel/qwidget_p.h
index 838236536a..71691a4afa 100644
--- a/src/widgets/kernel/qwidget_p.h
+++ b/src/widgets/kernel/qwidget_p.h
@@ -750,6 +750,7 @@ public:
#endif
#ifndef QT_NO_OPENGL
uint renderToTextureReallyDirty : 1;
+ uint renderToTextureComposeActive : 1;
#endif
// *************************** Platform specific ************************************
diff --git a/src/widgets/kernel/qwidgetbackingstore.cpp b/src/widgets/kernel/qwidgetbackingstore.cpp
index ecaba584f2..32aabcec9f 100644
--- a/src/widgets/kernel/qwidgetbackingstore.cpp
+++ b/src/widgets/kernel/qwidgetbackingstore.cpp
@@ -67,6 +67,8 @@ QT_BEGIN_NAMESPACE
extern QRegion qt_dirtyRegion(QWidget *);
+Q_GLOBAL_STATIC(QPlatformTextureList, qt_dummy_platformTextureList)
+
/**
* Flushes the contents of the \a backingStore into the screen area of \a widget.
* \a tlwOffset is the position of the top level widget relative to the window surface.
@@ -109,6 +111,20 @@ void QWidgetBackingStore::qt_flush(QWidget *widget, const QRegion &region, QBack
offset += widget->mapTo(tlw, QPoint());
#ifndef QT_NO_OPENGL
+ const bool compositionWasActive = widget->d_func()->renderToTextureComposeActive;
+ if (!widgetTextures) {
+ widget->d_func()->renderToTextureComposeActive = false;
+ // Detect the case of falling back to the normal flush path when no
+ // render-to-texture widgets are visible anymore. We will force one
+ // last flush to go through the OpenGL-based composition to prevent
+ // artifacts. The next flush after this one will use the normal path.
+ if (compositionWasActive)
+ widgetTextures = qt_dummy_platformTextureList;
+ } else {
+ widget->d_func()->renderToTextureComposeActive = true;
+ }
+
+ // re-test since we may have been forced to this path via the dummy texture list above
if (widgetTextures) {
qt_window_private(tlw->windowHandle())->compositing = true;
widget->window()->d_func()->sendComposeStatus(widget->window(), false);
@@ -970,8 +986,6 @@ static void findAllTextureWidgetsRecursively(QWidget *tlw, QWidget *widget)
}
}
-Q_GLOBAL_STATIC(QPlatformTextureList, qt_dummy_platformTextureList)
-
static QPlatformTextureList *widgetTexturesFor(QWidget *tlw, QWidget *widget)
{
foreach (QPlatformTextureList *tl, QWidgetPrivate::get(tlw)->topData()->widgetTextures) {
diff --git a/src/widgets/widgets/qabstractspinbox.cpp b/src/widgets/widgets/qabstractspinbox.cpp
index b33984e6c6..774f5a708d 100644
--- a/src/widgets/widgets/qabstractspinbox.cpp
+++ b/src/widgets/widgets/qabstractspinbox.cpp
@@ -1418,7 +1418,7 @@ QStyle::SubControl QAbstractSpinBoxPrivate::newHoverControl(const QPoint &pos)
QString QAbstractSpinBoxPrivate::stripped(const QString &t, int *pos) const
{
- QString text = t;
+ QStringRef text(&t);
if (specialValueText.size() == 0 || text != specialValueText) {
int from = 0;
int size = text.size();
@@ -1440,7 +1440,7 @@ QString QAbstractSpinBoxPrivate::stripped(const QString &t, int *pos) const
text = text.trimmed();
if (pos)
(*pos) -= (s - text.size());
- return text;
+ return text.toString();
}
diff --git a/src/widgets/widgets/qdockarealayout.cpp b/src/widgets/widgets/qdockarealayout.cpp
index 3b185a5e67..55e774024a 100644
--- a/src/widgets/widgets/qdockarealayout.cpp
+++ b/src/widgets/widgets/qdockarealayout.cpp
@@ -2168,6 +2168,9 @@ bool QDockAreaLayoutInfo::updateTabBar() const
if (oldCurrentId > 0 && currentTabId() != oldCurrentId)
that->setCurrentTabId(oldCurrentId);
+ if (QDockWidgetGroupWindow *dwgw = qobject_cast<QDockWidgetGroupWindow *>(tabBar->parent()))
+ dwgw->adjustFlags();
+
//returns if the tabbar is visible or not
return ( (gap ? 1 : 0) + tabBar->count()) > 1;
}
diff --git a/src/widgets/widgets/qdockwidget.cpp b/src/widgets/widgets/qdockwidget.cpp
index e8c5502ae6..d2fa9a7c06 100644
--- a/src/widgets/widgets/qdockwidget.cpp
+++ b/src/widgets/widgets/qdockwidget.cpp
@@ -1390,8 +1390,6 @@ void QDockWidget::changeEvent(QEvent *event)
if (QDockAreaLayoutInfo *info = winLayout->layoutState.dockAreaLayout.info(this))
info->updateTabBar();
}
- if (QDockWidgetGroupWindow *p = qobject_cast<QDockWidgetGroupWindow *>(parent()))
- p->adjustFlags();
}
#endif // QT_NO_TABBAR
break;
@@ -1481,9 +1479,6 @@ bool QDockWidget::event(QEvent *event)
}
if (!isFloating() && layout != 0 && onTop)
layout->raise(this);
- if (QDockWidgetGroupWindow *p = qobject_cast<QDockWidgetGroupWindow *>(parent()))
- p->adjustFlags();
-
break;
}
case QEvent::WindowActivate:
diff --git a/src/widgets/widgets/qtabbar.cpp b/src/widgets/widgets/qtabbar.cpp
index 8c808f98cb..fe04299b92 100644
--- a/src/widgets/widgets/qtabbar.cpp
+++ b/src/widgets/widgets/qtabbar.cpp
@@ -1413,13 +1413,13 @@ static QString computeElidedText(Qt::TextElideMode mode, const QString &text)
QString ret;
switch (mode) {
case Qt::ElideRight:
- ret = text.left(2) + Ellipses;
+ ret = text.leftRef(2) + Ellipses;
break;
case Qt::ElideMiddle:
- ret = text.left(1) + Ellipses + text.right(1);
+ ret = text.leftRef(1) + Ellipses + text.rightRef(1);
break;
case Qt::ElideLeft:
- ret = Ellipses + text.right(2);
+ ret = Ellipses + text.rightRef(2);
break;
case Qt::ElideNone:
ret = text;
diff --git a/src/widgets/widgets/qtextbrowser.cpp b/src/widgets/widgets/qtextbrowser.cpp
index 45da34c383..df92fc0e1e 100644
--- a/src/widgets/widgets/qtextbrowser.cpp
+++ b/src/widgets/widgets/qtextbrowser.cpp
@@ -302,7 +302,7 @@ void QTextBrowserPrivate::setSource(const QUrl &url)
qWarning("QTextBrowser: No document for %s", url.toString().toLatin1().constData());
if (q->isVisible()) {
- QString firstTag = txt.left(txt.indexOf(QLatin1Char('>')) + 1);
+ const QStringRef firstTag = txt.leftRef(txt.indexOf(QLatin1Char('>')) + 1);
if (firstTag.startsWith(QLatin1String("<qt")) && firstTag.contains(QLatin1String("type")) && firstTag.contains(QLatin1String("detail"))) {
#ifndef QT_NO_CURSOR
QApplication::restoreOverrideCursor();