diff options
| author | Martin T. H. Sandsmark <[email protected]> | 2020-04-07 17:14:59 +0200 |
|---|---|---|
| committer | Martin T. H. Sandsmark <[email protected]> | 2020-04-12 12:15:03 +0200 |
| commit | 35b4c6d4df1281afd621374e686f19e654ad7bae (patch) | |
| tree | 9fe02c65d102b15f60cec8031e323b3c8c4c16dc /src | |
| parent | d868568d81c74e91c37955876242ac1bed79133a (diff) | |
Fix crashing on starting and quitting
QCollator (especially with Qt 5.14 and ICU 65.1) is very unhappy with
threads.
To avoid having to lock and unlock the mutex everywhere (and ensure it
is unlocked before calling other things that might lock it, etc.), we do
it as locally as possible. Even if for some reason Qt and ICU make
QCollator threadsafe in the future locking here should have minimal
impact.
BUG: 419585
Differential Revision: https://phabricator.kde.org/D28659
Diffstat (limited to 'src')
| -rw-r--r-- | src/kitemviews/kfileitemmodel.cpp | 5 |
1 files changed, 5 insertions, 0 deletions
diff --git a/src/kitemviews/kfileitemmodel.cpp b/src/kitemviews/kfileitemmodel.cpp index 4b35a0248..e4dca2734 100644 --- a/src/kitemviews/kfileitemmodel.cpp +++ b/src/kitemviews/kfileitemmodel.cpp @@ -33,6 +33,9 @@ #include <QMimeData> #include <QTimer> #include <QWidget> +#include <QMutex> + +Q_GLOBAL_STATIC_WITH_ARGS(QMutex, s_collatorMutex, (QMutex::Recursive)) // #define KFILEITEMMODEL_DEBUG @@ -1878,6 +1881,8 @@ int KFileItemModel::sortRoleCompare(const ItemData* a, const ItemData* b, const int KFileItemModel::stringCompare(const QString& a, const QString& b, const QCollator& collator) const { + QMutexLocker collatorLock(s_collatorMutex()); + if (m_naturalSorting) { return collator.compare(a, b); } |
