summaryrefslogtreecommitdiff
path: root/font-viewer
diff options
context:
space:
mode:
authorraveit65 <[email protected]>2017-01-08 20:13:48 +0100
committerraveit65 <[email protected]>2017-02-17 12:28:22 +0100
commit97673116d6a7ff254c5d56d54c6cfb05002f751c (patch)
tree1eed69536a2a64b316dc483064b1d81d61199f96 /font-viewer
parentd030b2631145a38aa29920d7e3da4d84ea9081ab (diff)
downloadmate-control-center-97673116d6a7ff254c5d56d54c6cfb05002f751c.tar.bz2
mate-control-center-97673116d6a7ff254c5d56d54c6cfb05002f751c.tar.xz
Fontviewer: font-model, cancel previous loading when refreshing font list
This should help in case a refresh is requested before the previous operation completes. Currently, we seem to be crashing when that happens, see https://bugzilla.redhat.com/show_bug.cgi?id=870753 taken from: https://git.gnome.org/browse/gnome-font-viewer/commit/?id=47fbb29
Diffstat (limited to 'font-viewer')
-rw-r--r--font-viewer/font-model.c30
1 files changed, 25 insertions, 5 deletions
diff --git a/font-viewer/font-model.c b/font-viewer/font-model.c
index c7b79d5c..45077e39 100644
--- a/font-viewer/font-model.c
+++ b/font-viewer/font-model.c
@@ -50,6 +50,7 @@ struct _FontViewModelPrivate {
GList *monitors;
GdkPixbuf *fallback_icon;
+ GCancellable *cancellable;
};
enum {
@@ -360,11 +361,17 @@ load_font_infos (GIOSchedulerJob *job,
gint i;
GList *font_infos = NULL;
+ if (g_cancellable_is_cancelled (cancellable))
+ return FALSE;
+
for (i = 0; i < self->priv->font_list->nfont; i++) {
FontInfoData *font_info;
FcChar8 *file;
gchar *font_name;
+ if (g_cancellable_is_cancelled (cancellable))
+ break;
+
FcPatternGetString (self->priv->font_list->fonts[i], FC_FILE, 0, &file);
font_name = font_utils_get_font_name_for_file (self->priv->library, (const gchar *) file);
@@ -382,8 +389,11 @@ load_font_infos (GIOSchedulerJob *job,
data->self = g_object_ref (self);
data->font_infos = font_infos;
- g_io_scheduler_job_send_to_mainloop_async (job, font_infos_loaded,
- data, load_font_infos_data_free);
+ if (g_cancellable_is_cancelled (cancellable))
+ load_font_infos_data_free (data);
+ else
+ g_io_scheduler_job_send_to_mainloop_async (job, font_infos_loaded,
+ data, load_font_infos_data_free);
return FALSE;
}
@@ -396,8 +406,13 @@ ensure_font_list (FontViewModel *self)
FcObjectSet *os;
if (self->priv->font_list) {
- FcFontSetDestroy (self->priv->font_list);
- self->priv->font_list = NULL;
+ FcFontSetDestroy (self->priv->font_list);
+ self->priv->font_list = NULL;
+ }
+
+ if (self->priv->cancellable) {
+ g_cancellable_cancel (self->priv->cancellable);
+ g_clear_object (&self->priv->cancellable);
}
gtk_list_store_clear (GTK_LIST_STORE (self));
@@ -418,7 +433,7 @@ ensure_font_list (FontViewModel *self)
return;
g_io_scheduler_push_job (load_font_infos, self, NULL,
- G_PRIORITY_DEFAULT, NULL);
+ G_PRIORITY_DEFAULT, self->priv->cancellable);
}
static gboolean
@@ -557,6 +572,11 @@ font_view_model_finalize (GObject *obj)
{
FontViewModel *self = FONT_VIEW_MODEL (obj);
+ if (self->priv->cancellable) {
+ g_cancellable_cancel (self->priv->cancellable);
+ g_clear_object (&self->priv->cancellable);
+ }
+
if (self->priv->font_list) {
FcFontSetDestroy (self->priv->font_list);
self->priv->font_list = NULL;