[gimp/gimp-2-10] app: restore font list in async callback, not async-set notify handler
- From: Ell <ell src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gimp/gimp-2-10] app: restore font list in async callback, not async-set notify handler
- Date: Wed, 30 May 2018 16:59:31 +0000 (UTC)
commit 7c72d8cfa1c8ef6135534fccfcb4c9c53155ecff
Author: Ell <ell_se yahoo com>
Date: Wed May 30 12:46:16 2018 -0400
app: restore font list in async callback, not async-set notify handler
When font loading is finished, restore the font list in the
corresponding async completion callback, and not in the
"notify::empty" signal handler of the fonts async set
This solves a problem arising when gimp_fonts_wait() is called
*inside* a "notify::empty" signal handler, emitted when reloading
fonts (causing the "empty" property of the fonts async set to
switch from TRUE to FALSE): When the wait is over, "empty" will
switch back from FALSE to TRUE, however, since the "notify" signal
is non-recursive, the corresponding handler will not be called,
gimp_fonts_wait() will return *before* the font list is restored,
and the caller will see an empty font list. This can happen under
certain circumstances when reloading fonts while the text tool is
active.
(cherry picked from commit 0e19f159f570ec7727bbd5c9ebd7d51e46a9aa8c)
app/text/gimp-fonts.c | 55 +++++++++++++++++++--------------------------------
1 file changed, 20 insertions(+), 35 deletions(-)
---
diff --git a/app/text/gimp-fonts.c b/app/text/gimp-fonts.c
index b9e1e20f99..0483a74f71 100644
--- a/app/text/gimp-fonts.c
+++ b/app/text/gimp-fonts.c
@@ -48,21 +48,18 @@
#define CONF_FNAME "fonts.conf"
-static gboolean gimp_fonts_load_fonts_conf (FcConfig *config,
- GFile *fonts_conf);
-static void gimp_fonts_add_directories (Gimp *gimp,
- FcConfig *config,
- GList *path,
- GError **error);
-static void gimp_fonts_recursive_add_fontdir (FcConfig *config,
- GFile *path,
- GError **error);
-static void gimp_fonts_notify_font_path (GObject *gobject,
- GParamSpec *pspec,
- Gimp *gimp);
-static void gimp_fonts_async_set_notify_empty (GimpAsyncSet *async_set,
- GParamSpec *pspec,
- Gimp *gimp);
+static gboolean gimp_fonts_load_fonts_conf (FcConfig *config,
+ GFile *fonts_conf);
+static void gimp_fonts_add_directories (Gimp *gimp,
+ FcConfig *config,
+ GList *path,
+ GError **error);
+static void gimp_fonts_recursive_add_fontdir (FcConfig *config,
+ GFile *path,
+ GError **error);
+static void gimp_fonts_notify_font_path (GObject *gobject,
+ GParamSpec *pspec,
+ Gimp *gimp);
void
@@ -74,10 +71,6 @@ gimp_fonts_init (Gimp *gimp)
gimp_object_set_name (GIMP_OBJECT (gimp->fonts), "fonts");
gimp->fonts_async_set = gimp_async_set_new ();
-
- g_signal_connect (gimp->fonts_async_set, "notify::empty",
- G_CALLBACK (gimp_fonts_async_set_notify_empty),
- gimp);
}
void
@@ -97,10 +90,6 @@ gimp_fonts_exit (Gimp *gimp)
if (gimp->fonts_async_set)
{
- g_signal_handlers_disconnect_by_func (gimp->fonts_async_set,
- G_CALLBACK (gimp_fonts_async_set_notify_empty),
- gimp);
-
gimp_cancelable_cancel (GIMP_CANCELABLE (gimp->fonts_async_set));
g_clear_object (&gimp->fonts_async_set);
@@ -135,13 +124,18 @@ gimp_fonts_load_async (GimpAsync *async,
static void
gimp_fonts_load_async_callback (GimpAsync *async,
- gpointer data)
+ Gimp *gimp)
{
- if (gimp_async_is_finished (async) && ! gimp_async_is_canceled (async))
+ if (gimp_async_is_canceled (async))
+ return;
+
+ if (gimp_async_is_finished (async))
{
FcConfig *config = gimp_async_get_result (async);
FcConfigSetCurrent (config);
+
+ gimp_font_list_restore (GIMP_FONT_LIST (gimp->fonts));
}
}
@@ -200,7 +194,7 @@ gimp_fonts_load (Gimp *gimp,
gimp_async_add_callback (async,
(GimpAsyncCallback) gimp_fonts_load_async_callback,
- NULL);
+ gimp);
gimp_async_set_add (gimp->fonts_async_set, async);
@@ -431,12 +425,3 @@ gimp_fonts_notify_font_path (GObject *gobject,
g_error_free (error);
}
}
-
-static void
-gimp_fonts_async_set_notify_empty (GimpAsyncSet *async_set,
- GParamSpec *pspec,
- Gimp *gimp)
-{
- if (gimp_async_set_is_empty (async_set))
- gimp_font_list_restore (GIMP_FONT_LIST (gimp->fonts));
-}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]