diff options
author | Shaun McCance <shaunm@gnome.org> | 2009-10-27 01:00:58 -0500 |
---|---|---|
committer | Shaun McCance <shaunm@gnome.org> | 2009-10-27 01:00:58 -0500 |
commit | f3bc727b75592bdee2a3b09ac32259994752ddfc (patch) | |
tree | 78ac9c801274eb350444cf6849f874884105cf15 | |
parent | c73581c8c1c3f42c9e5d1475324002a46a8ca7c0 (diff) | |
download | yelp-f3bc727b75592bdee2a3b09ac32259994752ddfc.tar.gz |
[libyelp] Various race conditions and premature frees fixed.
It's hard, but not impossible, for a human to trigger these under normal
circumstances. I know there's at least one more hiding somewhere. Try
double-clicking links.
-rw-r--r-- | libyelp/yelp-mallard-document.c | 3 | ||||
-rw-r--r-- | libyelp/yelp-transform.c | 5 | ||||
-rw-r--r-- | libyelp/yelp-uri.c | 5 | ||||
-rw-r--r-- | tests/test-view.c | 11 |
4 files changed, 21 insertions, 3 deletions
diff --git a/libyelp/yelp-mallard-document.c b/libyelp/yelp-mallard-document.c index 1381cfc4..6afb5d19 100644 --- a/libyelp/yelp-mallard-document.c +++ b/libyelp/yelp-mallard-document.c @@ -536,7 +536,10 @@ mallard_page_data_run (MallardPageData *page_data) YelpMallardDocumentPrivate *priv = GET_PRIV (page_data->mallard); gint i, ix; gchar **params = NULL; + + mallard_page_data_cancel (page_data); page_data->transform = yelp_transform_new (); + /* FIXME: handle error */ yelp_transform_set_stylesheet (page_data->transform, STYLESHEET, NULL); diff --git a/libyelp/yelp-transform.c b/libyelp/yelp-transform.c index abf77acc..b337e742 100644 --- a/libyelp/yelp-transform.c +++ b/libyelp/yelp-transform.c @@ -180,6 +180,8 @@ yelp_transform_finalize (GObject *object) YelpTransformPrivate *priv = GET_PRIV (object); xsltDocumentPtr xsltdoc; + debug_print (DB_FUNCTION, "entering\n"); + if (priv->output) xmlFreeDoc (priv->output); if (priv->stylesheet) @@ -346,11 +348,12 @@ transform_run (YelpTransform *transform) priv->running = FALSE; if (!priv->cancelled) { g_idle_add ((GSourceFunc) transform_final, transform); + g_mutex_unlock (priv->mutex); } else { + g_mutex_unlock (priv->mutex); g_object_unref (transform); } - g_mutex_unlock (priv->mutex); } static gboolean diff --git a/libyelp/yelp-uri.c b/libyelp/yelp-uri.c index 605f30b6..e1d808bf 100644 --- a/libyelp/yelp-uri.c +++ b/libyelp/yelp-uri.c @@ -235,9 +235,11 @@ resolve_start (YelpUri *uri) { YelpUriPrivate *priv = GET_PRIV (uri); - if (priv->resolver == NULL) + if (priv->resolver == NULL) { + g_object_ref (uri); priv->resolver = g_thread_create ((GThreadFunc) resolve_async, uri, FALSE, NULL); + } } static void @@ -330,6 +332,7 @@ resolve_final (YelpUri *uri) } g_signal_emit (uri, uri_signals[RESOLVED], 0); + g_object_unref (uri); return FALSE; } diff --git a/tests/test-view.c b/tests/test-view.c index 57897bca..3858e37b 100644 --- a/tests/test-view.c +++ b/tests/test-view.c @@ -32,6 +32,10 @@ static void activate_cb (GtkEntry *entry, YelpView *view) { + /* I put in the double-load to test some race condition bugs. + * I decided to leave it in. + */ + yelp_view_load (view, gtk_entry_get_text (entry)); yelp_view_load (view, gtk_entry_get_text (entry)); } @@ -83,8 +87,13 @@ main (int argc, char **argv) g_signal_connect (entry, "activate", activate_cb, view); - if (argc >= 2) + if (argc >= 2) { + /* I put in the double-load to test some race condition bugs. + * I decided to leave it in. + */ + yelp_view_load (view, argv[1]); yelp_view_load (view, argv[1]); + } gtk_widget_show_all (GTK_WIDGET (window)); |