From 24c73420235bd9dd3f3f69819a522ee5b616ef96 Mon Sep 17 00:00:00 2001 From: Mitch Curtis Date: Tue, 12 Apr 2022 10:36:08 +0800 Subject: Fix flaky tst_QQuickFileDialogImpl::goUp test MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Don't listen to fileDialogListView currentIndexChanged signal while setting its currentIndex, because the file associated with the delegate is not correct at that stage. Change-Id: Iffc9315c03b6670bc3a7609f3613a4570e4f9632 Fixes: QTBUG-101488 Reviewed-by: Tor Arne Vestbø (cherry picked from commit dc86f974f0ce5ac57ddeceee3b020661b932f6b1) Reviewed-by: Fabian Kosmale --- .../quickdialogs2quickimpl/qquickfiledialogimpl.cpp | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) (limited to 'src/quickdialogs2/quickdialogs2quickimpl/qquickfiledialogimpl.cpp') diff --git a/src/quickdialogs2/quickdialogs2quickimpl/qquickfiledialogimpl.cpp b/src/quickdialogs2/quickdialogs2quickimpl/qquickfiledialogimpl.cpp index 02356b3bc2..4d37fee39a 100644 --- a/src/quickdialogs2/quickdialogs2quickimpl/qquickfiledialogimpl.cpp +++ b/src/quickdialogs2/quickdialogs2quickimpl/qquickfiledialogimpl.cpp @@ -148,7 +148,14 @@ void QQuickFileDialogImplPrivate::updateCurrentFile(const QString &oldFolderPath if (!newCurrentFilePath.isEmpty()) { q->setCurrentFile(QUrl::fromLocalFile(newCurrentFilePath)); - attached->fileDialogListView()->setCurrentIndex(newCurrentFileIndex); + { + // Set the appropriate currentIndex for the selected file. We block signals from ListView + // because we don't want fileDialogListViewCurrentIndexChanged to be called, as the file + // it gets from the delegate will not be up-to-date (but most importantly because we already + // just set the selected file). + QSignalBlocker blocker(attached->fileDialogListView()); + attached->fileDialogListView()->setCurrentIndex(newCurrentFileIndex); + } if (QQuickItem *currentItem = attached->fileDialogListView()->currentItem()) currentItem->forceActiveFocus(); } -- cgit v1.2.3