summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorChristian Ehrlicher <ch.ehrlicher@gmx.de>2023-12-17 11:28:27 +0100
committerChristian Ehrlicher <ch.ehrlicher@gmx.de>2023-12-18 11:15:22 +0100
commit87f7d2c6b076a4c275d4d14a1e099844c9eb4766 (patch)
tree7bc67da44668a98454984795bac872c7aa40e39e
parent03a4164206d64151da7e0b0f850063e501bdea57 (diff)
QPA/Windows: misc cleanup of QShGetFileInfoThread
Misc cleanup of QShGetFileInfoThread: - use QThread's interruption abilities instead custom one - use QMutexLocker instead manual lock/unlock Task-number: QTBUG-90876 Change-Id: If0566e56ab765fb95e837cdfa09639c1622b6d4e Reviewed-by: Friedemann Kleint <Friedemann.Kleint@qt.io> Reviewed-by: Oliver Wolff <oliver.wolff@qt.io>
-rw-r--r--src/plugins/platforms/windows/qwindowstheme.cpp12
1 files changed, 5 insertions, 7 deletions
diff --git a/src/plugins/platforms/windows/qwindowstheme.cpp b/src/plugins/platforms/windows/qwindowstheme.cpp
index aeb8d4ad1b..9022fe1406 100644
--- a/src/plugins/platforms/windows/qwindowstheme.cpp
+++ b/src/plugins/platforms/windows/qwindowstheme.cpp
@@ -180,8 +180,8 @@ public:
QComHelper comHelper(COINIT_MULTITHREADED);
QMutexLocker readyLocker(&m_readyMutex);
- while (!m_cancelled.loadRelaxed()) {
- if (!m_params && !m_cancelled.loadRelaxed()
+ while (!isInterruptionRequested()) {
+ if (!m_params && !isInterruptionRequested()
&& !m_readyCondition.wait(&m_readyMutex, QDeadlineTimer(1000ll)))
continue;
@@ -191,15 +191,14 @@ public:
const bool result = SHGetFileInfo(reinterpret_cast<const wchar_t *>(fileName.utf16()),
m_params->attributes, &info, sizeof(SHFILEINFO),
m_params->flags);
- m_doneMutex.lock();
- if (!m_cancelled.loadRelaxed()) {
+ QMutexLocker doneLocker(&m_doneMutex);
+ if (!isInterruptionRequested()) {
*m_params->result = result;
memcpy(m_params->info, &info, sizeof(SHFILEINFO));
}
m_params = nullptr;
m_doneCondition.wakeAll();
- m_doneMutex.unlock();
}
}
}
@@ -219,13 +218,12 @@ public:
void cancel()
{
QMutexLocker doneLocker(&m_doneMutex);
- m_cancelled.storeRelaxed(1);
+ requestInterruption();
m_readyCondition.wakeAll();
}
private:
QShGetFileInfoParams *m_params;
- QAtomicInt m_cancelled;
QWaitCondition m_readyCondition;
QWaitCondition m_doneCondition;
QMutex m_readyMutex;