using QGlobalStatic

This commit is contained in:
Uwe Rathmann 2017-12-01 09:33:13 +01:00
parent 698c29d925
commit 6644be15bd

View File

@ -8,6 +8,7 @@
#include "QskTextOptions.h" #include "QskTextOptions.h"
#include <QQuickWindow> #include <QQuickWindow>
#include <QGlobalStatic>
QSK_QT_PRIVATE_BEGIN QSK_QT_PRIVATE_BEGIN
#include <private/qquicktext_p.h> #include <private/qquicktext_p.h>
@ -97,15 +98,12 @@ namespace
better use different items as we might end up in events internally better use different items as we might end up in events internally
being sent, that leads to crashes because of it being sent, that leads to crashes because of it
*/ */
static TextItem* qskRenderHelper = nullptr; Q_GLOBAL_STATIC( TextItem, qskRenderHelper )
static TextItem* qskLayoutHelper = nullptr; Q_GLOBAL_STATIC( TextItem, qskLayoutHelper )
QSizeF QskRichTextRenderer::textSize( const QString& text, QSizeF QskRichTextRenderer::textSize( const QString& text,
const QFont& font, const QskTextOptions& options ) const QFont& font, const QskTextOptions& options )
{ {
if ( qskLayoutHelper == NULL )
qskLayoutHelper = new TextItem();
auto& item = *qskLayoutHelper; auto& item = *qskLayoutHelper;
item.begin(); item.begin();
@ -124,9 +122,6 @@ QSizeF QskRichTextRenderer::textSize( const QString& text,
QRectF QskRichTextRenderer::textRect( const QString& text, QRectF QskRichTextRenderer::textRect( const QString& text,
const QFont& font, const QskTextOptions& options, const QSizeF& size ) const QFont& font, const QskTextOptions& options, const QSizeF& size )
{ {
if ( qskLayoutHelper == NULL )
qskLayoutHelper = new TextItem();
auto& textItem = *qskLayoutHelper; auto& textItem = *qskLayoutHelper;
textItem.begin(); textItem.begin();
@ -154,9 +149,6 @@ void QskRichTextRenderer::updateNode( const QString& text,
// are we killing internal caches of QQuickText, when always using // are we killing internal caches of QQuickText, when always using
// the same item for the creation the text nodes. TODO ... // the same item for the creation the text nodes. TODO ...
if ( qskRenderHelper == NULL )
qskRenderHelper = new TextItem();
auto& textItem = *qskRenderHelper; auto& textItem = *qskRenderHelper;
textItem.begin(); textItem.begin();