From: acspike Date: Tue, 13 Jun 2006 02:38:04 +0000 (+0000) Subject: mental's patch for bug [ 1457003 ] X Window error with Composite: BadAlloc in stroke... X-Git-Url: https://git.tokkee.org/?a=commitdiff_plain;h=e13f85c3201f6a77108e894b995296b84902730a;p=inkscape.git mental's patch for bug [ 1457003 ] X Window error with Composite: BadAlloc in stroke style --- diff --git a/src/widgets/dash-selector.cpp b/src/widgets/dash-selector.cpp index 7b96451ac..78303c60b 100644 --- a/src/widgets/dash-selector.cpp +++ b/src/widgets/dash-selector.cpp @@ -56,6 +56,7 @@ static double **dashes = NULL; static void sp_dash_selector_class_init (SPDashSelectorClass *klass); static void sp_dash_selector_init (SPDashSelector *dsel); static GtkWidget *sp_dash_selector_menu_item_new (SPDashSelector *dsel, double *pattern); +static void sp_dash_selector_menu_item_image_realize (GtkWidget *mi, double *pattern); static void sp_dash_selector_dash_activate (GtkObject *object, SPDashSelector *dsel); static void sp_dash_selector_offset_value_changed (GtkAdjustment *adj, SPDashSelector *dsel); @@ -255,8 +256,22 @@ static GtkWidget * sp_dash_selector_menu_item_new (SPDashSelector *dsel, double *pattern) { GtkWidget *mi = gtk_menu_item_new (); + GtkWidget *px = gtk_image_new_from_pixmap (NULL, NULL); - GdkPixmap *pixmap = gdk_pixmap_new (GTK_WIDGET (dsel)->window, DASH_PREVIEW_LENGTH + 4, 16, gdk_visual_get_best_depth ()); + gtk_widget_show (px); + gtk_container_add (GTK_CONTAINER (mi), px); + + gtk_object_set_data (GTK_OBJECT (mi), "pattern", pattern); + gtk_object_set_data (GTK_OBJECT (mi), "px", px); + gtk_signal_connect (GTK_OBJECT (mi), "activate", G_CALLBACK (sp_dash_selector_dash_activate), dsel); + + g_signal_connect_after(G_OBJECT(px), "realize", G_CALLBACK(sp_dash_selector_menu_item_image_realize), pattern); + + return mi; +} + +static void sp_dash_selector_menu_item_image_realize (GtkWidget *px, double *pattern) { + GdkPixmap *pixmap = gdk_pixmap_new(px->window, DASH_PREVIEW_LENGTH + 4, 16, -1); GdkGC *gc = gdk_gc_new (pixmap); gdk_rgb_gc_set_foreground (gc, 0xffffffff); @@ -350,17 +365,8 @@ sp_dash_selector_menu_item_new (SPDashSelector *dsel, double *pattern) gdk_gc_unref (gc); - GtkWidget *px = gtk_pixmap_new (pixmap, NULL); - - gdk_pixmap_unref (pixmap); - - gtk_widget_show (px); - gtk_container_add (GTK_CONTAINER (mi), px); - - gtk_object_set_data (GTK_OBJECT (mi), "pattern", pattern); - gtk_signal_connect (GTK_OBJECT (mi), "activate", G_CALLBACK (sp_dash_selector_dash_activate), dsel); - - return mi; + gtk_image_set_from_pixmap(GTK_IMAGE(px), pixmap, NULL); + gdk_pixmap_unref(pixmap); } static void