From 02e2a3f123f08c473f8e79e5e245fd30c06448a6 Mon Sep 17 00:00:00 2001 From: Anton Kudryavtsev Date: Tue, 5 Sep 2023 11:20:12 +0300 Subject: [PATCH] qtextengine: use RAII more MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit replace new/delete with unique_ptr Change-Id: Iac36885041ee15bd2ecf6bb487dacf613e126475 Reviewed-by: MÃ¥rten Nordheim --- src/gui/text/qtextengine.cpp | 13 ++++--------- 1 file changed, 4 insertions(+), 9 deletions(-) diff --git a/src/gui/text/qtextengine.cpp b/src/gui/text/qtextengine.cpp index a0c7d0cf67c..a1c6bd27542 100644 --- a/src/gui/text/qtextengine.cpp +++ b/src/gui/text/qtextengine.cpp @@ -36,15 +36,10 @@ public: Itemizer(const QString &string, const QScriptAnalysis *analysis, QScriptItemArray &items) : m_string(string), m_analysis(analysis), - m_items(items), - m_splitter(nullptr) + m_items(items) { } - ~Itemizer() - { - delete m_splitter; - } - + ~Itemizer() = default; /// generate the script items /// The caps parameter is used to choose the algorithm of splitting text and assigning roles to the textitems void generate(int start, int length, QFont::Capitalization caps) @@ -101,7 +96,7 @@ private: return; if (!m_splitter) - m_splitter = new QTextBoundaryFinder(QTextBoundaryFinder::Word, + m_splitter = std::make_unique(QTextBoundaryFinder::Word, m_string.constData(), m_string.size(), /*buffer*/nullptr, /*buffer size*/0); @@ -171,7 +166,7 @@ private: const QString &m_string; const QScriptAnalysis * const m_analysis; QScriptItemArray &m_items; - QTextBoundaryFinder *m_splitter; + std::unique_ptr m_splitter; }; // -----------------------------------------------------------------------------------------------------