fc: Clean up current config on shutdown

The FontConfig database had a static leak because we never
dereferenced the current config. To make address sanitizer output
less noisy, we clean this up on shutdown.

From FcConfigDestroy docs: "Note that calling this function with the
return from FcConfigGetCurrent will cause a new configuration to be
created for use as current configuration."

So this should be safe even if application execution continues after
Qt shutdown, but it could trigger creation of a new current config
in that case, if FontConfig calls are made.

Fixes: QTBUG-92477
Pick-to: 5.15 6.1 6.2
Change-Id: I596055a84edc1a1b06157e2adf6c8627c6802db1
Reviewed-by: Lars Knoll <lars.knoll@qt.io>
This commit is contained in:
Eskil Abrahamsen Blomfeldt 2021-05-31 09:02:23 +02:00
parent 2ca19d2dd3
commit 4f730fc5f1
2 changed files with 6 additions and 0 deletions

View File

@ -557,6 +557,11 @@ static void populateFromPattern(FcPattern *pattern, QFontDatabasePrivate::Applic
}
QFontconfigDatabase::~QFontconfigDatabase()
{
FcConfigDestroy(FcConfigGetCurrent());
}
void QFontconfigDatabase::populateFontDatabase()
{
FcInit();

View File

@ -61,6 +61,7 @@ class QFontEngineFT;
class Q_GUI_EXPORT QFontconfigDatabase : public QFreeTypeFontDatabase
{
public:
~QFontconfigDatabase() override;
void populateFontDatabase() override;
void invalidate() override;
QFontEngineMulti *fontEngineMulti(QFontEngine *fontEngine, QChar::Script script) override;