From 8fb0a009d17c1ef2f429ab3f3bef27159870ff80 Mon Sep 17 00:00:00 2001 From: Mat Sutcliffe Date: Tue, 2 Apr 2019 13:47:36 +0100 Subject: [PATCH] Ref T579 Work around proximate cause of data race in CListModelBase. This is still not thread-safe but at least it is less likely to crash. A more robust fix will be attempted later. --- src/blackgui/models/listmodelbase.cpp | 3 ++- src/blackgui/models/listmodelbasenontemplate.h | 2 +- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/src/blackgui/models/listmodelbase.cpp b/src/blackgui/models/listmodelbase.cpp index d93788f2d..e5fa8ef25 100644 --- a/src/blackgui/models/listmodelbase.cpp +++ b/src/blackgui/models/listmodelbase.cpp @@ -545,10 +545,11 @@ namespace BlackGui } // sort the values + const auto tieBreakersCopy = m_sortTieBreakers; //! \todo workaround T579 still not thread-safe, but less likely to crash const std::integral_constant marker {}; const auto p = [ = ](const ObjectType & a, const ObjectType & b) -> bool { - return Private::compareForModelSort(a, b, order, propertyIndex, m_sortTieBreakers, marker); + return Private::compareForModelSort(a, b, order, propertyIndex, tieBreakersCopy, marker); }; return container.sorted(p); diff --git a/src/blackgui/models/listmodelbasenontemplate.h b/src/blackgui/models/listmodelbasenontemplate.h index d7399c5f2..f40428ed5 100644 --- a/src/blackgui/models/listmodelbasenontemplate.h +++ b/src/blackgui/models/listmodelbasenontemplate.h @@ -165,7 +165,7 @@ namespace BlackGui CColumns m_columns; //!< columns metadata int m_sortColumn; //!< currently sorted column - bool m_modelDestroyed = false; //!< model is about to be destroyed + bool m_modelDestroyed = false; //!< \todo rudimentary workaround for T579, can be removed Qt::SortOrder m_sortOrder; //!< sort order (asc/desc) Qt::DropActions m_dropActions = Qt::IgnoreAction; //!< drop actions BlackMisc::CPropertyIndexList m_sortTieBreakers; //!< how column values are sorted if equal, if no value is given this is random