Skip to content
Permalink
Browse files
Lazy initialize QFontDatabase member in QgsPalLayerSettings
This probably shouldn't even be here at all...
  • Loading branch information
nyalldawson committed Apr 27, 2021
1 parent 6f94fce commit 298de15f91b1d947d8c2c605e5f0922496916de9
Showing with 8 additions and 3 deletions.
  1. +7 −2 src/core/labeling/qgspallabeling.cpp
  2. +1 −1 src/core/labeling/qgspallabeling.h
@@ -3009,7 +3009,10 @@ void QgsPalLayerSettings::parseTextStyle( QFont &labelFont,
if ( !ddFontFamily.isEmpty() )
{
// both family and style are different, build font from database
QFont styledfont = mFontDB.font( ddFontFamily, ddFontStyle, appFont.pointSize() );
if ( !mFontDB )
mFontDB = std::make_unique< QFontDatabase >();

QFont styledfont = mFontDB->font( ddFontFamily, ddFontStyle, appFont.pointSize() );
if ( appFont != styledfont )
{
newFont = styledfont;
@@ -3025,7 +3028,9 @@ void QgsPalLayerSettings::parseTextStyle( QFont &labelFont,
if ( ddFontStyle.compare( QLatin1String( "Ignore" ), Qt::CaseInsensitive ) != 0 )
{
// just family is different, build font from database
QFont styledfont = mFontDB.font( ddFontFamily, mFormat.namedStyle(), appFont.pointSize() );
if ( !mFontDB )
mFontDB = std::make_unique< QFontDatabase >();
QFont styledfont = mFontDB->font( ddFontFamily, mFormat.namedStyle(), appFont.pointSize() );
if ( appFont != styledfont )
{
newFont = styledfont;
@@ -1071,7 +1071,7 @@ class CORE_EXPORT QgsPalLayerSettings

QgsExpression *expression = nullptr;

QFontDatabase mFontDB;
std::unique_ptr< QFontDatabase > mFontDB;

QgsTextFormat mFormat;

0 comments on commit 298de15

Please sign in to comment.