[gnome-documents/gnome-3-8] nav-bar: fix a crash when disposing while thumbnail in progress
- From: Cosimo Cecchi <cosimoc src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-documents/gnome-3-8] nav-bar: fix a crash when disposing while thumbnail in progress
- Date: Tue, 16 Apr 2013 01:24:31 +0000 (UTC)
commit a7b457f39e935212e732087cbb955e78ecff2420
Author: Cosimo Cecchi <cosimoc gnome org>
Date: Mon Apr 1 15:06:49 2013 -0400
nav-bar: fix a crash when disposing while thumbnail in progress
We didn't disconnect the thumbnail job signal and cancel it in
dispose(), so when the widget was destroyed with thumbnail jobs in
progress, we would access invalid memory from the job callback.
src/lib/gd-nav-bar.c | 33 +++++++++++++++++++--------------
1 file changed, 19 insertions(+), 14 deletions(-)
---
diff --git a/src/lib/gd-nav-bar.c b/src/lib/gd-nav-bar.c
index 9b945b5..ed7ac97 100644
--- a/src/lib/gd-nav-bar.c
+++ b/src/lib/gd-nav-bar.c
@@ -279,6 +279,18 @@ thumbnail_job_completed_cb (EvJobThumbnail *job,
}
static void
+preview_item_clear_thumbnail_job (GdNavBar *self,
+ PreviewItem *item)
+{
+ if (item->job != NULL) {
+ g_signal_handlers_disconnect_by_func (item->job, thumbnail_job_completed_cb, self);
+ ev_job_cancel (item->job);
+ }
+
+ g_clear_object (&item->job);
+}
+
+static void
previews_clear_range (GdNavBar *self,
int start_page,
int end_page)
@@ -290,10 +302,8 @@ previews_clear_range (GdNavBar *self,
for (i = start_page; i < end_page; i++) {
PreviewItem *item = &self->priv->previews[i];
- if (item != NULL && item->job != NULL) {
- g_signal_handlers_disconnect_by_func (item->job, thumbnail_job_completed_cb, self);
- ev_job_cancel (item->job);
- g_clear_object (&item->job);
+ if (item != NULL) {
+ preview_item_clear_thumbnail_job (self, item);
}
}
}
@@ -395,15 +405,6 @@ previews_create (GdNavBar *self)
}
static void
-preview_item_clear (PreviewItem *item)
-{
- g_clear_object (&item->job);
- g_clear_object (&item->pixbuf);
- g_free (item->label);
- item->label = NULL;
-}
-
-static void
previews_clear (GdNavBar *self)
{
int i;
@@ -415,7 +416,11 @@ previews_clear (GdNavBar *self)
for (i = 0; i < self->priv->n_pages; i++) {
PreviewItem *item = &self->priv->previews[i];
- preview_item_clear (item);
+ preview_item_clear_thumbnail_job (self, item);
+
+ g_clear_object (&item->pixbuf);
+ g_free (item->label);
+ item->label = NULL;
}
g_free (self->priv->previews);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]