From f0db72c89b298445d5cff978e20768dd017dcf81 Mon Sep 17 00:00:00 2001 From: Roman Telezhynskyi Date: Mon, 16 Jan 2023 11:40:00 +0200 Subject: [PATCH] Replace static private variable with Q_GLOBAL_STATIC. --- src/libs/vlayout/vtextmanager.cpp | 15 ++++++++++----- src/libs/vlayout/vtextmanager.h | 1 - 2 files changed, 10 insertions(+), 6 deletions(-) diff --git a/src/libs/vlayout/vtextmanager.cpp b/src/libs/vlayout/vtextmanager.cpp index f3880a064..adec81999 100644 --- a/src/libs/vlayout/vtextmanager.cpp +++ b/src/libs/vlayout/vtextmanager.cpp @@ -35,6 +35,7 @@ #include #include // QFlags #include +#include #include "../ifc/xml/vabstractpattern.h" #include "../vpatterndb/floatItemData/vpiecelabeldata.h" @@ -108,10 +109,14 @@ auto operator>>(QDataStream &dataStream, TextLine &data) -> QDataStream& return dataStream; } -QVector VTextManager::m_patternLabelLines = QVector(); const quint32 VTextManager::streamHeader = 0x47E6A9EE; // CRC-32Q string "VTextManager" const quint16 VTextManager::classVersion = 1; +namespace +{ +Q_GLOBAL_STATIC(QVector, m_patternLabelLines) // NOLINT +} + // Friend functions //--------------------------------------------------------------------------------------------------------------------- auto operator<<(QDataStream &dataStream, const VTextManager &data) -> QDataStream& @@ -650,10 +655,10 @@ void VTextManager::Update(VAbstractPattern *pDoc, const VContainer *pattern) { m_liLines.clear(); - if (m_patternLabelLines.isEmpty() || pDoc->GetPatternWasChanged()) + if (m_patternLabelLines->isEmpty() || pDoc->GetPatternWasChanged()) { QVector lines = pDoc->GetPatternLabelTemplate(); - if (lines.isEmpty() && m_patternLabelLines.isEmpty()) + if (lines.isEmpty() && m_patternLabelLines->isEmpty()) { return; // Nothing to parse } @@ -666,8 +671,8 @@ void VTextManager::Update(VAbstractPattern *pDoc, const VContainer *pattern) } pDoc->SetPatternWasChanged(false); - m_patternLabelLines = PrepareLines(lines); + *m_patternLabelLines = PrepareLines(lines); } - m_liLines = m_patternLabelLines; + m_liLines = *m_patternLabelLines; } diff --git a/src/libs/vlayout/vtextmanager.h b/src/libs/vlayout/vtextmanager.h index 0c9ecdf03..31ae47be5 100644 --- a/src/libs/vlayout/vtextmanager.h +++ b/src/libs/vlayout/vtextmanager.h @@ -102,7 +102,6 @@ private: QFont m_font; QVector m_liLines; - static QVector m_patternLabelLines; static const quint32 streamHeader; static const quint16 classVersion; };