mirror of
https://github.com/swift-project/pilotclient.git
synced 2026-05-01 22:55:41 +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 <QMetaEnum>
|
||||||
#include <QStringBuilder>
|
#include <QStringBuilder>
|
||||||
|
#include <QThreadStorage>
|
||||||
|
|
||||||
namespace BlackMisc
|
namespace BlackMisc
|
||||||
{
|
{
|
||||||
namespace Private
|
namespace Private
|
||||||
{
|
{
|
||||||
|
QThreadStorage<QString> t_tempBuffer; // thread_local would be destroyed before function-scope statics, see T495
|
||||||
|
|
||||||
QString arg(QStringView format, const QStringList &args)
|
QString arg(QStringView format, const QStringList &args)
|
||||||
{
|
{
|
||||||
if (format.isEmpty())
|
if (format.isEmpty())
|
||||||
@@ -30,7 +33,7 @@ namespace BlackMisc
|
|||||||
return args.join(u' ');
|
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
|
temp.resize(0); // unlike clear(), resize(0) doesn't release the capacity if there are no implicitly shared copies
|
||||||
|
|
||||||
for (auto it = format.begin(); ; )
|
for (auto it = format.begin(); ; )
|
||||||
|
|||||||
Reference in New Issue
Block a user