Skip to content

Commit

Permalink
Lazy initialize QFontDatabase member in QgsPalLayerSettings
Browse files Browse the repository at this point in the history
This probably shouldn't even be here at all...
  • Loading branch information
nyalldawson committed Apr 27, 2021
1 parent 6f94fce commit 298de15
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 3 deletions.
9 changes: 7 additions & 2 deletions src/core/labeling/qgspallabeling.cpp
Expand Up @@ -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;
Expand All @@ -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;
Expand Down
2 changes: 1 addition & 1 deletion src/core/labeling/qgspallabeling.h
Expand Up @@ -1071,7 +1071,7 @@ class CORE_EXPORT QgsPalLayerSettings

QgsExpression *expression = nullptr;

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

QgsTextFormat mFormat;

Expand Down

0 comments on commit 298de15

Please sign in to comment.