Merge lp:~charlesk/overlay-scrollbar/lp-1058205 into lp:overlay-scrollbar

Proposed by Charles Kerr
Status: Merged
Merged at revision: 357
Proposed branch: lp:~charlesk/overlay-scrollbar/lp-1058205
Merge into: lp:overlay-scrollbar
Diff against target: 151 lines (+66/-48)
1 file modified
os/os-scrollbar.c (+66/-48)
To merge this branch: bzr merge lp:~charlesk/overlay-scrollbar/lp-1058205
Reviewer Review Type Date Requested Status
jenkins (community) continuous-integration Approve
Thomas Bechtold (community) Approve
Andrea Cimitan Approve
Review via email: mp+128087@code.launchpad.net

Description of the change

This is based off Thomas' fix-mem-leak-bug-1058205 branch.

While I was testing Thomas' branch, I noticed his test case reported the overlay scrollbar created these Priv structs while the scrollbars were being disposed. This has two problems -- first is the unnecessary work of creating and populating a Priv struct only to dispose it; but more importantly, we're allocating memory and setting it in an object's qdata after the object's been disposed.

So, this branch contains Thomas' slice_free() fix and also avoids creating Privs in our hijacked_scrollbar_dispose() callback.

To post a comment you must log in.
Revision history for this message
Andrea Cimitan (cimi) wrote :

Fine for me, there's an extra white line before the new static function :)

review: Approve
Revision history for this message
jenkins (martin-mrazik+qa) wrote :
review: Needs Fixing (continuous-integration)
Revision history for this message
Thomas Bechtold (toabctl) wrote :

Looks good to me. The Jenkins links are all 404 :(

review: Approve
Revision history for this message
jenkins (martin-mrazik+qa) wrote :
review: Approve (continuous-integration)

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'os/os-scrollbar.c'
--- os/os-scrollbar.c 2012-08-29 16:09:23 +0000
+++ os/os-scrollbar.c 2012-10-04 18:48:20 +0000
@@ -607,14 +607,29 @@
607}607}
608#endif608#endif
609609
610/* Get the private struct. */610
611/* destroy the private struct */
612static void
613destroy_private (gpointer priv)
614{
615 g_slice_free (OsScrollbarPrivate, priv);
616}
617
618/* Get the private struct. If there isn't one, return NULL */
619static OsScrollbarPrivate*
620lookup_private (GtkWidget *widget)
621{
622 return g_object_get_qdata (G_OBJECT (widget), os_quark_qdata);
623}
624
625/* Get the private struct. If there isn't one, create it */
611static OsScrollbarPrivate*626static OsScrollbarPrivate*
612get_private (GtkWidget *widget)627get_private (GtkWidget *widget)
613{628{
614 OsScrollbarPrivate *priv;629 OsScrollbarPrivate *priv;
615630
616 /* Fetch the private qdata struct. */631 /* Fetch the private qdata struct. */
617 priv = g_object_get_qdata (G_OBJECT (widget), os_quark_qdata);632 priv = lookup_private (widget);
618633
619 if (!priv)634 if (!priv)
620 {635 {
@@ -665,7 +680,7 @@
665 scrolling_cb, scrolling_end_cb, widget);680 scrolling_cb, scrolling_end_cb, widget);
666681
667 /* Store qdata. */682 /* Store qdata. */
668 g_object_set_qdata (G_OBJECT (widget), os_quark_qdata, qdata);683 g_object_set_qdata_full (G_OBJECT (widget), os_quark_qdata, qdata, destroy_private);
669 priv = qdata;684 priv = qdata;
670685
671 /* Create adjustment and thumb. */686 /* Create adjustment and thumb. */
@@ -3173,31 +3188,6 @@
3173 OsScrollbarPrivate *priv;3188 OsScrollbarPrivate *priv;
31743189
3175 scrollbar = GTK_SCROLLBAR (object);3190 scrollbar = GTK_SCROLLBAR (object);
3176 priv = get_private (GTK_WIDGET (scrollbar));
3177
3178 if (priv->source_deactivate_bar_id != 0)
3179 {
3180 g_source_remove (priv->source_deactivate_bar_id);
3181 priv->source_deactivate_bar_id = 0;
3182 }
3183
3184 if (priv->source_hide_thumb_id != 0)
3185 {
3186 g_source_remove (priv->source_hide_thumb_id);
3187 priv->source_hide_thumb_id = 0;
3188 }
3189
3190 if (priv->source_show_thumb_id != 0)
3191 {
3192 g_source_remove (priv->source_show_thumb_id);
3193 priv->source_show_thumb_id = 0;
3194 }
3195
3196 if (priv->source_unlock_thumb_id != 0)
3197 {
3198 g_source_remove (priv->source_unlock_thumb_id);
3199 priv->source_unlock_thumb_id = 0;
3200 }
32013191
3202 os_root_list = g_slist_remove (os_root_list, scrollbar);3192 os_root_list = g_slist_remove (os_root_list, scrollbar);
32033193
@@ -3213,26 +3203,54 @@
3213 root_filter_func, NULL);3203 root_filter_func, NULL);
3214 }3204 }
32153205
3216 if (priv->animation != NULL)3206 priv = lookup_private (GTK_WIDGET(scrollbar));
3217 {3207 if (priv != NULL)
3218 g_object_unref (priv->animation);3208 {
3219 priv->animation = NULL;3209 if (priv->source_deactivate_bar_id != 0)
3220 }3210 {
32213211 g_source_remove (priv->source_deactivate_bar_id);
3222 if (priv->bar != NULL)3212 priv->source_deactivate_bar_id = 0;
3223 {3213 }
3224 g_object_unref (priv->bar);3214
3225 priv->bar = NULL;3215 if (priv->source_hide_thumb_id != 0)
3226 }3216 {
32273217 g_source_remove (priv->source_hide_thumb_id);
3228 if (priv->window_group != NULL)3218 priv->source_hide_thumb_id = 0;
3229 {3219 }
3230 g_object_unref (priv->window_group);3220
3231 priv->window_group = NULL;3221 if (priv->source_show_thumb_id != 0)
3232 }3222 {
32333223 g_source_remove (priv->source_show_thumb_id);
3234 swap_adjustment (scrollbar, NULL);3224 priv->source_show_thumb_id = 0;
3235 swap_thumb (scrollbar, NULL);3225 }
3226
3227 if (priv->source_unlock_thumb_id != 0)
3228 {
3229 g_source_remove (priv->source_unlock_thumb_id);
3230 priv->source_unlock_thumb_id = 0;
3231 }
3232
3233 if (priv->animation != NULL)
3234 {
3235 g_object_unref (priv->animation);
3236 priv->animation = NULL;
3237 }
3238
3239 if (priv->bar != NULL)
3240 {
3241 g_object_unref (priv->bar);
3242 priv->bar = NULL;
3243 }
3244
3245 if (priv->window_group != NULL)
3246 {
3247 g_object_unref (priv->window_group);
3248 priv->window_group = NULL;
3249 }
3250
3251 swap_adjustment (scrollbar, NULL);
3252 swap_thumb (scrollbar, NULL);
3253 }
3236 }3254 }
32373255
3238 (* pre_hijacked_scrollbar_dispose) (object);3256 (* pre_hijacked_scrollbar_dispose) (object);

Subscribers

People subscribed via source and target branches