summaryrefslogtreecommitdiffstats
path: root/src/gui/itemmodels/qfileinfogatherer_p.h
Commit message (Collapse)AuthorAgeFilesLines
* Try harder to clean up the file info gatherer without blockingVolker Hilsheimer2023-12-161-1/+5
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | QFileSystemModel uses a QFileInfoGatherer, which is a QThread, to populate itself with the data from the file system. Some of the system calls we make for that might block, e.g. on Windows a disconnected network can easily result in 10 minutes of timeout. Destroying the QFileSystemModel destroyed the QFileInfoGatherer class member instance, and the QFileInfoGatherer destructor, being a QThread, had to wait on itself to avoid QThread asserting when being destroyed while still running. This means that shutting down a Qt application that was using a QFileSystemModel, e.g. through the non-native QFileDialog, would hang practically indefinitely instead of shutting down. To fix this, explicitly manage the life-time of the QFileInfoGatherer. Manage it in QFileSystemModel through a std::unique_ptr instead of as a direct class member so that we can control its destruction. In the QFileSystemModel destructor, signal the gather to terminate and wait one it for one second. If that fails, schedule the gatherer for later deletion through deleteLater(), and release it from the unique_ptr. The QFileInfoGatherer instance might then be alive with the QFileSystemModel destroyed. When it receives the DeferredDelete event, try again to abort the process and wait on the thread, this time for 5 seconds. If that also fails, then we have to make a choice. We cannot destroy the QThread object while it's still running, so we have to either wait indefinitely, terminate the thread, or accept a memory leak by ignoring the deferred delete event. If the QCoreApplication is shutting down, then we terminate the thread. To make this safe, explicitly control when termination is allowed in the thread - disallow it while the thread is holding a mutex, allow it while the thread is performing I/O operations. If the QCoreApplication is not shutting down, then we connect to the QThread::finished signal, and delete the object in response to that. This might or might not happen, in which case we have to accept that there's a memory leak. Pick-to: 6.7 6.6 Fixes: QTBUG-120062 Change-Id: I1e4243265879d61cf406b4eeb0b11b9d59b006ad Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
* QFileInfoGatherer: port away from QPairAhmad Samir2023-12-061-3/+4
| | | | | | Task-number: QTBUG-115841 Change-Id: I06c39140fb9afbbe6352af1025387d1890ca2730 Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
* QFileSystemModel: add lastModified() overload that takes a QTimeZoneAhmad Samir2023-01-061-3/+3
| | | | | | | | | | | | | | | | | | | | This is useful when sorting by time and using QTimeZone::UTC, since native filesystem API uses UTC, that means less conversions, which is potentially faster. Use UTC internally except for strings that are going to be shown in a GUI to the user, these should be in QTimeZone::LocalTime. [ChangeLog][QtGui][QFileSystemModel] Added lastModified() overload that takes a QTimeZone, this is useful when e.g. comparing file timestamps and all that's needed is time in UTC (this is faster as no time zone conversions is required). QTimeZone::UTC is used internally when sorting by time (using the sort() function), which should ideally make it faster too. Task-number: QTBUG-100349 Change-Id: I0e58f8eb7856b8da7d55db86ddd2c009ff83d970 Reviewed-by: Kai Köhne <kai.koehne@qt.io>
* Use SPDX license identifiersLucie Gérard2022-05-161-38/+2
| | | | | | | | | | | | | Replace the current license disclaimer in files by a SPDX-License-Identifier. Files that have to be modified by hand are modified. License files are organized under LICENSES directory. Task-number: QTBUG-67283 Change-Id: Id880c92784c40f3bbde861c0d93f58151c18b9f1 Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: Lars Knoll <lars.knoll@qt.io> Reviewed-by: Jörg Bornemann <joerg.bornemann@qt.io>
* QtGui: replace remaining uses of QLatin1String with QLatin1StringViewSona Kurazyan2022-04-281-1/+1
| | | | | | Task-number: QTBUG-98434 Change-Id: I98c27030c783f968cbf38dc966ce486dc366b302 Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
* Move QFileSystemModel into QtGuiVolker Hilsheimer2020-08-251-0/+230
This requires a QAbstractFileIconProvider in QtGui, as the standard QFileIconProvider depends on QStyle, and cannot be moved out of QtWidgets. QAbstractFileIconProvider returns strings for file types, but returns no icons yet. Support for a default icon set might be added in a follow-up commit. Change-Id: Ib9d095cd612fdcf04db62f2e40709fcffe3dc2b7 Fixes: QTBUG-66177 Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>