mirror of
https://github.com/swift-project/pilotclient.git
synced 2026-04-20 20:40:29 +08:00
Move function-scope static QThreadStorage objects to namespace scope
to ensure destruction after all function-scope statics and avoid warning "thread exited after QThreadStorage destroyed".
This commit is contained in:
@@ -116,6 +116,8 @@ namespace BlackGui
|
|||||||
return (mw && mw->isFrameless());
|
return (mw && mw->isFrameless());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static QThreadStorage<QRegularExpression> tsRegex;
|
||||||
|
|
||||||
bool CGuiUtility::lenientTitleComparison(const QString &title, const QString &comparison)
|
bool CGuiUtility::lenientTitleComparison(const QString &title, const QString &comparison)
|
||||||
{
|
{
|
||||||
if (title == comparison) { return true; }
|
if (title == comparison) { return true; }
|
||||||
@@ -127,7 +129,6 @@ namespace BlackGui
|
|||||||
if (t == c) { return true; }
|
if (t == c) { return true; }
|
||||||
|
|
||||||
// further unify
|
// further unify
|
||||||
static QThreadStorage<QRegularExpression> tsRegex;
|
|
||||||
if (! tsRegex.hasLocalData()) { tsRegex.setLocalData(QRegularExpression("[^a-z0-9\\s]")); }
|
if (! tsRegex.hasLocalData()) { tsRegex.setLocalData(QRegularExpression("[^a-z0-9\\s]")); }
|
||||||
const QRegularExpression ®exp = tsRegex.localData();
|
const QRegularExpression ®exp = tsRegex.localData();
|
||||||
t = t.remove(regexp);
|
t = t.remove(regexp);
|
||||||
|
|||||||
@@ -50,6 +50,9 @@ namespace BlackMisc
|
|||||||
//! \threadsafe
|
//! \threadsafe
|
||||||
inline std::mt19937 &defaultRandomGenerator()
|
inline std::mt19937 &defaultRandomGenerator()
|
||||||
{
|
{
|
||||||
|
//! \fixme Move rng to namespace scope to ensure destruction after function-local statics
|
||||||
|
//! and avoid warning "thread exited after QThreadStorage destroyed".
|
||||||
|
//! This will require careful thought about linkage.
|
||||||
static QThreadStorage<std::mt19937> rng;
|
static QThreadStorage<std::mt19937> rng;
|
||||||
if (rng.hasLocalData()) { rng.setLocalData(std::mt19937(static_cast<std::mt19937::result_type>(QRandomGenerator::global()->generate()))); }
|
if (rng.hasLocalData()) { rng.setLocalData(std::mt19937(static_cast<std::mt19937::result_type>(QRandomGenerator::global()->generate()))); }
|
||||||
return rng.localData();
|
return rng.localData();
|
||||||
|
|||||||
@@ -17,11 +17,12 @@
|
|||||||
|
|
||||||
namespace BlackMisc
|
namespace BlackMisc
|
||||||
{
|
{
|
||||||
|
static QThreadStorage<std::vector<const CJsonScope *>> g_stack;
|
||||||
|
|
||||||
//! \private
|
//! \private
|
||||||
auto &jsonStack() noexcept
|
auto &jsonStack() noexcept
|
||||||
{
|
{
|
||||||
static QThreadStorage<std::vector<const CJsonScope *>> stack;
|
return g_stack.localData();
|
||||||
return stack.localData();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// pin vtables to this file
|
// pin vtables to this file
|
||||||
|
|||||||
@@ -114,7 +114,7 @@ namespace BlackMisc
|
|||||||
static const CLogCategoryList &fromClass()
|
static const CLogCategoryList &fromClass()
|
||||||
{
|
{
|
||||||
static_assert(sizeof(T) > 0, "T must be a complete type, not forward declared");
|
static_assert(sizeof(T) > 0, "T must be a complete type, not forward declared");
|
||||||
static QThreadStorage<CLogCategoryList> list;
|
static QThreadStorage<CLogCategoryList> list; //! \todo C++17: make list an inline static member variable template
|
||||||
if (! list.hasLocalData())
|
if (! list.hasLocalData())
|
||||||
{
|
{
|
||||||
list.localData().appendCategoriesFromMemberFunction(tag<T>(), THasGetLogCategories<T>());
|
list.localData().appendCategoriesFromMemberFunction(tag<T>(), THasGetLogCategories<T>());
|
||||||
|
|||||||
Reference in New Issue
Block a user