summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorQt Forward Merge Bot <qt_forward_merge_bot@qt-project.org>2018-10-02 03:00:10 +0200
committerQt Forward Merge Bot <qt_forward_merge_bot@qt-project.org>2018-10-02 03:00:10 +0200
commitc0ea6c87a07387792310746118d523d9541203c0 (patch)
tree4e19cd6db37b6f1e4adecae5000f6a2f530a6b11
parent8d1de951f0993e1f4ed1a26a34f197acac7eef4c (diff)
parent352be75dec15cb333f58d0075d89b2ebc7a2e46b (diff)
downloadqtquickcontrols-c0ea6c87a07387792310746118d523d9541203c0.tar.gz
Merge remote-tracking branch 'origin/5.12' into dev
Change-Id: Ibb1d26d59fb131e9fbdbcdd4a9009e96f0cb10a9
-rw-r--r--src/controls/Private/ScrollViewHelper.qml18
-rw-r--r--src/controls/qquickmenu.cpp75
-rw-r--r--src/controls/qquickmenu_p.h2
-rw-r--r--src/widgets/qquickqfiledialog_p.h6
-rw-r--r--tests/auto/controls/data/tst_scrollview.qml26
5 files changed, 84 insertions, 43 deletions
diff --git a/src/controls/Private/ScrollViewHelper.qml b/src/controls/Private/ScrollViewHelper.qml
index 810de91d..53050108 100644
--- a/src/controls/Private/ScrollViewHelper.qml
+++ b/src/controls/Private/ScrollViewHelper.qml
@@ -68,31 +68,29 @@ Item {
anchors.fill: parent
- property bool recursionGuard: false
-
- function doLayout() {
- if (!recursionGuard) {
- recursionGuard = true
+ Timer {
+ id: layoutTimer
+ interval: 0;
+ onTriggered: {
blockUpdates = true;
scrollHelper.contentWidth = flickableItem !== null ? flickableItem.contentWidth : 0
scrollHelper.contentHeight = flickableItem !== null ? flickableItem.contentHeight : 0
scrollHelper.availableWidth = viewport.width
scrollHelper.availableHeight = viewport.height
blockUpdates = false;
- recursionGuard = false
}
}
Connections {
target: viewport
- onWidthChanged: doLayout()
- onHeightChanged: doLayout()
+ onWidthChanged: layoutTimer.running = true
+ onHeightChanged: layoutTimer.running = true
}
Connections {
target: flickableItem
- onContentWidthChanged: doLayout()
- onContentHeightChanged: doLayout()
+ onContentWidthChanged: layoutTimer.running = true
+ onContentHeightChanged: layoutTimer.running = true
onContentXChanged: {
hscrollbar.flash()
vscrollbar.flash()
diff --git a/src/controls/qquickmenu.cpp b/src/controls/qquickmenu.cpp
index 3c6d91ef..bfa0f673 100644
--- a/src/controls/qquickmenu.cpp
+++ b/src/controls/qquickmenu.cpp
@@ -789,33 +789,41 @@ void QQuickMenu1::insertItem(int index, QQuickMenuBase1 *menuItem)
void QQuickMenu1::removeItem(QQuickMenuBase1 *menuItem)
{
- if (!menuItem)
- return;
- menuItem->setParentMenu(0);
-
- QQuickMenuItemContainer1 *container = menuItem->parent() != this ? m_containers[menuItem->parent()] : 0;
- if (container)
- container->removeItem(menuItem);
- else
- m_menuItems.removeOne(menuItem);
-
- --m_itemsCount;
- emit itemsChanged();
+ // Removes the item, but if it's a container, the container is kept
+ if (menuItem) {
+ unparentItem(menuItem);
+ emit itemsChanged();
+ }
}
void QQuickMenu1::clear()
{
- m_containers.clear();
- m_containersCount = 0;
+ if (m_itemsCount > 0) {
+ while (m_itemsCount > 0)
+ unparentItem(menuItemAtIndex(0));
- // QTBUG-48927: a proxy menu (ApplicationWindowStyle.qml) must not
- // delete its items, because they are owned by the menubar
- if (m_proxy)
+ // We can delete the containers now, as there cannot be any further items in them.
+ qDeleteAll(m_containers);
+ m_containers.clear();
+ m_containersCount = 0;
+
+ // The containers are also kept in m_menuItems, so we have to clear explicitly.
m_menuItems.clear();
- while (!m_menuItems.empty())
- delete m_menuItems.takeFirst();
- m_itemsCount = 0;
+ emit itemsChanged();
+ }
+}
+
+void QQuickMenu1::unparentItem(QQuickMenuBase1 *menuItem)
+{
+ menuItem->setParentMenu(nullptr);
+ QQuickMenuItemContainer1 *container = (menuItem->parent() != this)
+ ? m_containers[menuItem->parent()] : nullptr;
+ if (container)
+ container->removeItem(menuItem);
+ else
+ m_menuItems.removeOne(menuItem);
+ --m_itemsCount;
}
void QQuickMenu1::setupMenuItem(QQuickMenuBase1 *item, int platformIndex)
@@ -871,8 +879,31 @@ QObject *QQuickMenu1::at_menuItems(QQuickMenuItems *list, int index)
void QQuickMenu1::clear_menuItems(QQuickMenuItems *list)
{
- if (QQuickMenu1 *menu = qobject_cast<QQuickMenu1 *>(list->object))
- menu->clear();
+ if (QQuickMenu1 *menu = qobject_cast<QQuickMenu1 *>(list->object)) {
+ // There may be stray containers that don't appear in m_menuItems. This is because we may
+ // remove a container with removeItem(), which will only remove it from m_menuItems.
+ // Therefore, make sure that all containers are removed from m_menuItems first.
+ for (QQuickMenuItemContainer1 *container : menu->m_containers)
+ menu->m_menuItems.removeOne(container);
+
+ // Delete or unparent the items first. They may have references to the containers.
+ // QTBUG-48927: a proxy menu (ApplicationWindowStyle.qml) must not
+ // delete its items, because they are owned by the menubar
+ // We still do own the containers, though. We create them on append_menuItems, after all.
+ while (!menu->m_menuItems.empty()) {
+ if (menu->m_proxy)
+ menu->unparentItem(menu->m_menuItems[0]);
+ else
+ delete menu->m_menuItems.takeFirst();
+ }
+ menu->m_menuItems.clear();
+
+ qDeleteAll(menu->m_containers);
+ menu->m_containers.clear();
+ menu->m_containersCount = 0;
+
+ menu->m_itemsCount = 0;
+ }
}
QT_END_NAMESPACE
diff --git a/src/controls/qquickmenu_p.h b/src/controls/qquickmenu_p.h
index 800981dd..0594f391 100644
--- a/src/controls/qquickmenu_p.h
+++ b/src/controls/qquickmenu_p.h
@@ -190,6 +190,8 @@ private:
static int count_menuItems(QQuickMenuItems *list);
static QObject *at_menuItems(QQuickMenuItems *list, int index);
static void clear_menuItems(QQuickMenuItems *list);
+
+ void unparentItem(QQuickMenuBase1 *menuItem);
void setupMenuItem(QQuickMenuBase1 *item, int platformIndex = -1);
QPlatformMenu *m_platformMenu;
diff --git a/src/widgets/qquickqfiledialog_p.h b/src/widgets/qquickqfiledialog_p.h
index d977e345..4988c1e0 100644
--- a/src/widgets/qquickqfiledialog_p.h
+++ b/src/widgets/qquickqfiledialog_p.h
@@ -51,11 +51,13 @@
// We mean it.
//
-#include <QFileDialog>
-#include "../dialogs/qquickabstractfiledialog_p.h"
+#include <QtWidgets/qtwidgetsglobal.h>
#if QT_CONFIG(filedialog)
+#include <QFileDialog>
+#include "../dialogs/qquickabstractfiledialog_p.h"
+
QT_BEGIN_NAMESPACE
class QQuickQFileDialog : public QQuickAbstractFileDialog
diff --git a/tests/auto/controls/data/tst_scrollview.qml b/tests/auto/controls/data/tst_scrollview.qml
index 42398115..d3bfac4b 100644
--- a/tests/auto/controls/data/tst_scrollview.qml
+++ b/tests/auto/controls/data/tst_scrollview.qml
@@ -212,21 +212,27 @@ TestCase {
bigItem.height = 100
bigItem.width = 100
- verify(!scrollView.__horizontalScrollBar.visible, "Scrollbar showing when contents already fit")
- verify(!scrollView.__verticalScrollBar.visible, "Scrollbar showing when contents already fit")
+ tryVerify(function() { return !scrollView.__horizontalScrollBar.visible }, 50,
+ "Scrollbar showing when contents already fit")
+ tryVerify(function() { return !scrollView.__verticalScrollBar.visible }, 50,
+ "Scrollbar showing when contents already fit")
bigItem.height = 1000
bigItem.width = 1000
- verify(scrollView.__horizontalScrollBar.visible, "Scrollbar not showing when contents are too big")
- verify(scrollView.__verticalScrollBar.visible, "Scrollbar not showing when contents are too big")
+ tryVerify(function() { return scrollView.__horizontalScrollBar.visible }, 50,
+ "Scrollbar not showing when contents are too big")
+ tryVerify(function() { return scrollView.__verticalScrollBar.visible }, 50,
+ "Scrollbar not showing when contents are too big")
//always off
bigItem.height = 1000
scrollView.verticalScrollBarPolicy = Qt.ScrollBarAlwaysOff
- verify(!scrollView.__verticalScrollBar.visible, "Scrollbar showing when disabled")
+ tryVerify(function() { return !scrollView.__verticalScrollBar.visible }, 50,
+ "Scrollbar showing when disabled")
bigItem.height = 100
- verify(!scrollView.__verticalScrollBar.visible, "Scrollbar showing when disabled")
+ tryVerify(function() { return !scrollView.__verticalScrollBar.visible }, 50,
+ "Scrollbar showing when disabled")
//always on
scrollView.verticalScrollBarPolicy = Qt.ScrollBarAlwaysOn
@@ -258,12 +264,14 @@ TestCase {
verify(scrollView !== null, "view created is null")
verify(scrollView.flickableItem.contentY === 0)
+ tryVerify(function() { return scrollView.__verticalScrollBar.visible });
+
mouseClick(scrollView, scrollView.width -2, scrollView.height/2, Qt.LeftButton)
- verify(Math.round(scrollView.flickableItem.contentY) === 100)
+ tryVerify(function() { return Math.round(scrollView.flickableItem.contentY) === 100 });
- verify(scrollView.flickableItem.contentX === 0)
+ tryVerify(function() { return scrollView.flickableItem.contentX === 0 })
mouseClick(scrollView, scrollView.width/2, scrollView.height - 2, Qt.LeftButton)
- verify(Math.round(scrollView.flickableItem.contentX) === 100)
+ tryVerify(function() { return Math.round(scrollView.flickableItem.contentX) === 100 })
}
function test_viewport() {