Replace static private variable with Q_GLOBAL_STATIC.

(cherry picked from commit f0db72c89b)
This commit is contained in:
Roman Telezhynskyi 2023-01-16 11:40:00 +02:00
parent 0d50387980
commit cc0ae88921
2 changed files with 10 additions and 6 deletions

View file

@ -35,6 +35,7 @@
#include <QDebug> #include <QDebug>
#include <QFlags> // QFlags<Qt::Alignment> #include <QFlags> // QFlags<Qt::Alignment>
#include <QtMath> #include <QtMath>
#include <QGlobalStatic>
#include "../ifc/xml/vabstractpattern.h" #include "../ifc/xml/vabstractpattern.h"
#include "../vpatterndb/floatItemData/vpiecelabeldata.h" #include "../vpatterndb/floatItemData/vpiecelabeldata.h"
@ -108,10 +109,14 @@ auto operator>>(QDataStream &dataStream, TextLine &data) -> QDataStream&
return dataStream; return dataStream;
} }
QVector<TextLine> VTextManager::m_patternLabelLines = QVector<TextLine>();
const quint32 VTextManager::streamHeader = 0x47E6A9EE; // CRC-32Q string "VTextManager" const quint32 VTextManager::streamHeader = 0x47E6A9EE; // CRC-32Q string "VTextManager"
const quint16 VTextManager::classVersion = 1; const quint16 VTextManager::classVersion = 1;
namespace
{
Q_GLOBAL_STATIC(QVector<TextLine>, m_patternLabelLines) // NOLINT
}
// Friend functions // Friend functions
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
auto operator<<(QDataStream &dataStream, const VTextManager &data) -> QDataStream& auto operator<<(QDataStream &dataStream, const VTextManager &data) -> QDataStream&
@ -650,10 +655,10 @@ void VTextManager::Update(VAbstractPattern *pDoc, const VContainer *pattern)
{ {
m_liLines.clear(); m_liLines.clear();
if (m_patternLabelLines.isEmpty() || pDoc->GetPatternWasChanged()) if (m_patternLabelLines->isEmpty() || pDoc->GetPatternWasChanged())
{ {
QVector<VLabelTemplateLine> lines = pDoc->GetPatternLabelTemplate(); QVector<VLabelTemplateLine> lines = pDoc->GetPatternLabelTemplate();
if (lines.isEmpty() && m_patternLabelLines.isEmpty()) if (lines.isEmpty() && m_patternLabelLines->isEmpty())
{ {
return; // Nothing to parse return; // Nothing to parse
} }
@ -666,8 +671,8 @@ void VTextManager::Update(VAbstractPattern *pDoc, const VContainer *pattern)
} }
pDoc->SetPatternWasChanged(false); pDoc->SetPatternWasChanged(false);
m_patternLabelLines = PrepareLines(lines); *m_patternLabelLines = PrepareLines(lines);
} }
m_liLines = m_patternLabelLines; m_liLines = *m_patternLabelLines;
} }

View file

@ -102,7 +102,6 @@ private:
QFont m_font; QFont m_font;
QVector<TextLine> m_liLines; QVector<TextLine> m_liLines;
static QVector<TextLine> m_patternLabelLines;
static const quint32 streamHeader; static const quint32 streamHeader;
static const quint16 classVersion; static const quint16 classVersion;
}; };