From 818bcecc7ce816f5ec273f88d4bbc92d303cfbc0 Mon Sep 17 00:00:00 2001 From: raveit65 Date: Sun, 8 Jan 2017 17:48:44 +0100 Subject: Fontviewer: move FontConfig init/deinit to the application class Safely init FontConfig once for the whole app, and de-init it when quitting. taken from: https://git.gnome.org/browse/gnome-font-viewer/commit/?id=beec585 --- font-viewer/font-view.c | 14 ++++++++++++++ 1 file changed, 14 insertions(+) (limited to 'font-viewer/font-view.c') diff --git a/font-viewer/font-view.c b/font-viewer/font-view.c index a62a75e8..4457fe16 100644 --- a/font-viewer/font-view.c +++ b/font-viewer/font-view.c @@ -31,6 +31,7 @@ #include FT_SFNT_NAMES_H #include FT_TRUETYPE_IDS_H #include +#include #include #include #include @@ -654,6 +655,14 @@ font_view_application_activate (GApplication *application) font_view_application_do_overview (self); } +static void +font_view_application_quit_mainloop (GApplication *application) +{ + G_APPLICATION_CLASS (font_view_application_parent_class)->quit_mainloop (application); + + FcFini (); +} + static void font_view_application_dispose (GObject *obj) { @@ -679,6 +688,7 @@ font_view_application_class_init (FontViewApplicationClass *klass) aclass->activate = font_view_application_activate; aclass->startup = font_view_application_startup; aclass->open = font_view_application_open; + aclass->quit_mainloop = font_view_application_quit_mainloop; oclass->dispose = font_view_application_dispose; } @@ -687,6 +697,10 @@ static GApplication * font_view_application_new (void) { g_type_init (); + + if (!FcInit ()) + g_critical ("Can't initialize fontconfig library"); + return g_object_new (FONT_VIEW_TYPE_APPLICATION, "application-id", "org.mate.font-viewer", "flags", G_APPLICATION_HANDLES_OPEN, -- cgit v1.2.1