QFileSystemModel: Wake file info gatherer thread up before waiting on it

Amends 0786c17bbc556a0f494fc825af47c604a9dc0241, which added a number
of attempts to gracefully shut down the QFileInfoGatherer thread while
shutting down a QFileSystemModel. This introduced a 1-second wait upon
destruction of the model when the QFileInfoGatherer thread is waiting
for an unset wait condition.

Instead of QThread::requestInteruption() to make the thread exit, use
QFileInfoGatherer::requestAbort(), which calls requestInteruption() but
also sets the wait condition afterwards to make sure that the thread
wakes up and checks the abort condition.

Pick-to: 6.6
Fixes: QTBUG-124164
Change-Id: I560f2131f226e0bb59f72e558cbab55b89cfb144
Reviewed-by: David Faure <david.faure@kdab.com>
(cherry picked from commit a79ca35abef38f882a1ab574063eb9ed6ffe6846)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
This commit is contained in:
Volker Hilsheimer 2024-04-08 11:48:20 +02:00 committed by Qt Cherry-pick Bot
parent 8b193397f5
commit 32270a1276

View File

@ -2079,7 +2079,7 @@ QFileSystemModelPrivate::QFileSystemModelPrivate()
QFileSystemModelPrivate::~QFileSystemModelPrivate()
{
#if QT_CONFIG(filesystemwatcher)
fileInfoGatherer->requestInterruption();
fileInfoGatherer->requestAbort();
if (!fileInfoGatherer->wait(1000)) {
// If the thread hangs, perhaps because the network was disconnected
// while the gatherer was stat'ing a remote file, then don't block