commit 33da74a9ab13bba4f46b2455cc858c7ae02bd923 Author: Cody Russell Date: Mon Mar 31 08:51:25 2014 -0500 This is an attempt to solve an issue in GtkNSView that occurs in Xamarin Studio when we try to use an animating NSProgressIndicator. The error only occurred if the indicator was in animating mode, and it seems likely to be a threading race condition somewhere. This patch does two things. I've found the issue to be reproducible if we do one of these things but not the other, but I have not been able to reproduce it with both of these. First, we slightly defer the mapping of the widget. Second, we lock the view during clip_to_parent_viewports(). https://bugzilla.xamarin.com/show_bug.cgi?id=17401 diff --git a/gtk/gtknsview.c b/gtk/gtknsview.c index d5eb307..31c4970 100644 --- a/gtk/gtknsview.c +++ b/gtk/gtknsview.c @@ -280,6 +280,7 @@ clip_to_parent_viewports (GtkNSView *ns_view, ns_view = get_associated_gtknsview (self); + [self lockFocusIfCanDraw]; if (ns_view) cg_context = clip_to_parent_viewports (ns_view, self); @@ -287,6 +288,8 @@ clip_to_parent_viewports (GtkNSView *ns_view, if (cg_context) CGContextRestoreGState (cg_context); + + [self unlockFocus]; } @end @@ -566,15 +569,17 @@ gtk_ns_view_unrealize (GtkWidget *widget) GTK_WIDGET_CLASS (gtk_ns_view_parent_class)->unrealize (widget); } -static void -gtk_ns_view_map (GtkWidget *widget) -{ +static gboolean +really_map (GtkWidget *widget) { GtkNSView *ns_view = GTK_NS_VIEW (widget); GtkWidget *toplevel = gtk_widget_get_toplevel (widget); GtkAllocation allocation; NSView *parent_view; NSWindow *window; + if (gtk_widget_get_mapped (widget)) + return FALSE; + gtk_widget_get_allocation (widget, &allocation); gtk_ns_view_position_view (ns_view, &allocation); @@ -605,6 +610,14 @@ gtk_ns_view_map (GtkWidget *widget) gtk_ns_view_swizzle_draw_rect_recursive (text, "gtkwindow", toplevel); } } + + return FALSE; +} + +static void +gtk_ns_view_map (GtkWidget *widget) +{ + g_timeout_add (50, (GSourceFunc)really_map, widget); } static void