mirror of
https://github.com/swift-project/pilotclient.git
synced 2026-04-02 15:15:50 +08:00
Ref T495 Using QThreadStorage because thread_local caused a static destruction order fiasco.
This commit is contained in:
@@ -18,11 +18,14 @@
|
||||
|
||||
#include <QMetaEnum>
|
||||
#include <QStringBuilder>
|
||||
#include <QThreadStorage>
|
||||
|
||||
namespace BlackMisc
|
||||
{
|
||||
namespace Private
|
||||
{
|
||||
QThreadStorage<QString> t_tempBuffer; // thread_local would be destroyed before function-scope statics, see T495
|
||||
|
||||
QString arg(QStringView format, const QStringList &args)
|
||||
{
|
||||
if (format.isEmpty())
|
||||
@@ -30,7 +33,7 @@ namespace BlackMisc
|
||||
return args.join(u' ');
|
||||
}
|
||||
|
||||
thread_local QString temp;
|
||||
QString &temp = t_tempBuffer.localData();
|
||||
temp.resize(0); // unlike clear(), resize(0) doesn't release the capacity if there are no implicitly shared copies
|
||||
|
||||
for (auto it = format.begin(); ; )
|
||||
|
||||
Reference in New Issue
Block a user