gnome-gtkhtml-editor segfaults because of the new color-combo widget



Hi,

Somebody can tell me if this patch seem correct ?

Christian

From: reebalazs freemail hu
Subject: Bug#101156: gnome-gtkhtml-editor segfaults because of the new color-combo widget
To:  <submit bugs debian org>
Date: Sun, 17 Jun 2001 02:15:45 +0200 (CEST)
Reply-To: reebalazs freemail hu, 101156 bugs debian org
Resent-From: reebalazs freemail hu

Package: gtkhtml
Version: 0.9.2-2

When testing evolution 0.10-2, I noticed that gnome-gtkhtml-editor segfaults
at startup. Performing a few quick tests with the test-editor I realized
that the error is due to the new version of the color-combo widget in the
libgal7 library. Having looked at the code of gnumeric, I identified the
following two issues:

1. the signature of the color_combo_new function is changed, so perhaps it is
necessary to call color_group_fetch before calling it.

2. the signature of the "changed" signal of the color-combo widget is different
from the previous version.

Although I am not sure if the following quick changes are good solutions for
the problem, but they solve the segfaults for me. As far as the ColorGroups are
concerned, I think they ought to be handled more carefully than in my solution.

This would also solve bug #100120 reported against the package evolution.

The changes I tried affect three source files.

--- gtkhtml-0.9.2.orig/components/html-editor/body.c
+++ gtkhtml-0.9.2/components/html-editor/body.c
@@ -75,10 +75,15 @@
 }

 static void
-color_changed (GtkWidget *w, GdkColor *color, GtkHTMLEditBodyProperties *data)
+color_changed (GtkWidget *w, GdkColor *color,
+		gboolean by_user, GtkHTMLEditBodyProperties *data)
 {
 	gint idx;

+	/* Color was set programatically, bail out */
+	if (!by_user)
+		return;
+
 	idx = GPOINTER_TO_INT (gtk_object_get_data (GTK_OBJECT (w), "type"));
 	data->color [idx] = color
 		? *color
@@ -119,6 +124,7 @@
 	GtkWidget *hbox, *vbox, *frame, *combo, *table;
 	GSList *group;
 	HTMLColor *color;
+	ColorGroup *cg;

 	*set_data = data;
 	data->cd = cd;
@@ -162,9 +168,10 @@
         data->color [ct] = html_colorset_get_color_allocated (cd->html->engine->painter, ct)->color; \
         color = html_colorset_get_color (cd->html->engine->defaultSettings->color_set, ct); \
         html_color_alloc (color, cd->html->engine->painter); \
+	cg = color_group_fetch("body_" g, NULL); \
 	combo = color_combo_new (NULL, _("Automatic"), \
 				 &color->color, \
-				 "body_" g); \
+				 cg); \
         color_combo_set_color (COLOR_COMBO (combo), &data->color [ct]); \
         gtk_object_set_data (GTK_OBJECT (combo), "type", GINT_TO_POINTER (ct)); \
         gtk_signal_connect (GTK_OBJECT (combo), "changed", GTK_SIGNAL_FUNC (color_changed), data); \
--- gtkhtml-0.9.2.orig/components/html-editor/text.c
+++ gtkhtml-0.9.2/components/html-editor/text.c
@@ -93,8 +93,13 @@
 }

 static void
-color_changed (GtkWidget *w, GdkColor *color, GtkHTMLEditTextProperties *data)
+color_changed (GtkWidget *w, GdkColor *color,
+		gboolean by_user, GtkHTMLEditTextProperties *data)
 {
+	/* Color was set programatically, bail out */
+	if (!by_user)
+		return;
+
 	html_color_unref (data->color);
 	data->color = color
 		&& color != &html_colorset_get_color (data->cd->html->engine->settings->color_set, HTMLTextColor)->color
@@ -149,6 +154,7 @@
 	GtkHTMLEditTextProperties *data = g_new (GtkHTMLEditTextProperties, 1);
 	GtkWidget *vbox, *frame, *table, *menu, *menuitem, *hbox;
 	gint i;
+	ColorGroup *cg;

 	*set_data = data;

@@ -218,9 +224,10 @@
 	frame = gtk_frame_new (_("Color"));
 	hbox = gtk_hbox_new (FALSE, 0);
 	gtk_container_set_border_width (GTK_CONTAINER (hbox), 3);
+	cg = color_group_fetch("text", NULL);
 	data->color_combo = color_combo_new (NULL, _("Automatic"),
 					     &html_colorset_get_color (data->cd->html->engine->settings->color_set,
-								       HTMLTextColor)->color, "text");
+								       HTMLTextColor)->color, cg);
         gtk_signal_connect (GTK_OBJECT (data->color_combo), "changed", GTK_SIGNAL_FUNC (color_changed), data);

 	vbox = gtk_vbox_new (FALSE, 0);
--- gtkhtml-0.9.2.orig/components/html-editor/toolbar.c
+++ gtkhtml-0.9.2/components/html-editor/toolbar.c
@@ -221,12 +221,19 @@
 }

 static void
-color_changed (GtkWidget *w, GdkColor *gdk_color, GtkHTMLControlData *cd)
+color_changed (GtkWidget *w, GdkColor *gdk_color,
+		gboolean by_user, GtkHTMLControlData *cd)
 {
-	HTMLColor *color = gdk_color
+	HTMLColor *color;
+
+	/* Color was set programatically, bail out */
+	if (!by_user)
+		return;
+
+	color = gdk_color
 		&& gdk_color != &html_colorset_get_color (cd->html->engine->settings->color_set, HTMLTextColor)->color
 		? html_color_new_from_gdk_color (gdk_color) : NULL;
-
+
 	gtk_html_set_color (cd->html, color);
 	if (color)
 		html_color_unref (color);
@@ -265,7 +272,9 @@
 setup_color_combo (GtkHTMLControlData *cd)
 {
 	HTMLColor *color;
+	ColorGroup *cg;

+
 	color = html_colorset_get_color (cd->html->engine->settings->color_set, HTMLTextColor);
 	if (GTK_WIDGET_REALIZED (cd->html))
 		html_color_alloc (color, cd->html->engine->painter);
@@ -273,7 +282,8 @@
 		gtk_signal_connect (GTK_OBJECT (cd->html), "realize", realize_engine, cd);
         gtk_signal_connect (GTK_OBJECT (cd->html), "load_done", GTK_SIGNAL_FUNC (load_done), cd);

-	cd->combo = color_combo_new (NULL, _("Automatic"), &color->color, "toolbar_text");
+	cg = color_group_fetch("toolbar_text", NULL);
+	cd->combo = color_combo_new (NULL, _("Automatic"), &color->color, cg);
 	GTK_WIDGET_UNSET_FLAGS (cd->combo, GTK_CAN_FOCUS);
 	gtk_container_forall (GTK_CONTAINER (cd->combo), unset_focus, NULL);
         gtk_signal_connect (GTK_OBJECT (cd->combo), "changed", GTK_SIGNAL_FUNC (color_changed), cd);





[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]