diff options
author | raveit65 <[email protected]> | 2017-01-08 17:48:44 +0100 |
---|---|---|
committer | raveit65 <[email protected]> | 2017-02-17 12:28:22 +0100 |
commit | 818bcecc7ce816f5ec273f88d4bbc92d303cfbc0 (patch) | |
tree | eb1187c75811c3362dbc2d2eacfd64fe2eba8454 | |
parent | c67f9e98c102a579271dcf549db6ef5ae600901a (diff) | |
download | mate-control-center-818bcecc7ce816f5ec273f88d4bbc92d303cfbc0.tar.bz2 mate-control-center-818bcecc7ce816f5ec273f88d4bbc92d303cfbc0.tar.xz |
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
-rw-r--r-- | font-viewer/font-model.c | 2 | ||||
-rw-r--r-- | font-viewer/font-view.c | 14 |
2 files changed, 14 insertions, 2 deletions
diff --git a/font-viewer/font-model.c b/font-viewer/font-model.c index 6681b842..9a365527 100644 --- a/font-viewer/font-model.c +++ b/font-viewer/font-model.c @@ -440,8 +440,6 @@ font_view_model_init (FontViewModel *self) self->priv = G_TYPE_INSTANCE_GET_PRIVATE (self, FONT_VIEW_TYPE_MODEL, FontViewModelPrivate); - if (!FcInit()) - g_critical ("Can't initialize fontconfig library"); if (FT_Init_FreeType (&self->priv->library) != FT_Err_Ok) g_critical ("Can't initialize FreeType library"); 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 <cairo/cairo-ft.h> +#include <fontconfig/fontconfig.h> #include <gio/gio.h> #include <gtk/gtk.h> #include <glib/gi18n.h> @@ -655,6 +656,14 @@ font_view_application_activate (GApplication *application) } 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) { FontViewApplication *self = FONT_VIEW_APPLICATION (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, |