[evolution] Bug #589580 - Crashes when dragging an image to the contact editor



commit 20da1867ea97adc3b1e07b759aafd276e1c6c75a
Author: Milan Crha <mcrha redhat com>
Date:   Fri Jul 24 11:31:21 2009 +0200

    Bug #589580 - Crashes when dragging an image to the contact editor

 addressbook/gui/contact-editor/e-contact-editor.c |    4 ++--
 addressbook/gui/widgets/eab-gui-util.c            |    3 ++-
 widgets/misc/e-image-chooser.c                    |   17 ++++++++++-------
 3 files changed, 14 insertions(+), 10 deletions(-)
---
diff --git a/addressbook/gui/contact-editor/e-contact-editor.c b/addressbook/gui/contact-editor/e-contact-editor.c
index abcfe8c..fc4c8ff 100644
--- a/addressbook/gui/contact-editor/e-contact-editor.c
+++ b/addressbook/gui/contact-editor/e-contact-editor.c
@@ -2201,7 +2201,7 @@ fill_in_simple_field (EContactEditor *editor, GtkWidget *widget, gint field_id)
 			editor->image_set = TRUE;
 		}
 		else {
-			gchar *file_name = e_icon_factory_get_icon_filename ("stock_person", 48);
+			gchar *file_name = e_icon_factory_get_icon_filename ("stock_person", GTK_ICON_SIZE_DIALOG);
 			e_image_chooser_set_from_file (E_IMAGE_CHOOSER (widget), file_name);
 			editor->image_set = FALSE;
 			g_free (file_name);
@@ -2766,7 +2766,7 @@ image_cleared (EContactEditor *editor)
 
 	image_chooser = glade_xml_get_widget (editor->gui, "image-chooser");
 
-	file_name = e_icon_factory_get_icon_filename ("stock_person", 48);
+	file_name = e_icon_factory_get_icon_filename ("stock_person", GTK_ICON_SIZE_DIALOG);
 
 	g_signal_handlers_block_by_func (image_chooser, image_chooser_changed, editor);
 	e_image_chooser_set_from_file (E_IMAGE_CHOOSER (image_chooser), file_name);
diff --git a/addressbook/gui/widgets/eab-gui-util.c b/addressbook/gui/widgets/eab-gui-util.c
index 87601d7..c11ff53 100644
--- a/addressbook/gui/widgets/eab-gui-util.c
+++ b/addressbook/gui/widgets/eab-gui-util.c
@@ -1023,7 +1023,8 @@ eab_create_image_chooser_widget(gchar *name,
 	if (string1) {
 		filename = e_icon_factory_get_icon_filename (string1, GTK_ICON_SIZE_DIALOG);
 
-		e_image_chooser_set_from_file (E_IMAGE_CHOOSER (w), filename);
+		if (filename && *filename)
+			e_image_chooser_set_from_file (E_IMAGE_CHOOSER (w), filename);
 
 		g_free (filename);
 	}
diff --git a/widgets/misc/e-image-chooser.c b/widgets/misc/e-image-chooser.c
index 2893cae..e5a20e5 100644
--- a/widgets/misc/e-image-chooser.c
+++ b/widgets/misc/e-image-chooser.c
@@ -31,6 +31,8 @@
 #include "e-util/e-icon-factory.h"
 #include "e-util/e-util.h"
 
+#define d(x)
+
 struct _EImageChooserPrivate {
 
 	GtkWidget *frame;
@@ -244,17 +246,17 @@ set_image_from_data (EImageChooser *chooser,
 		new_height = gdk_pixbuf_get_height (pixbuf);
 		new_width = gdk_pixbuf_get_width (pixbuf);
 
-		printf ("new dimensions = (%d,%d)\n", new_width, new_height);
+		d (printf ("new dimensions = (%d,%d)\n", new_width, new_height));
 
 		if (chooser->priv->image_height == 0
 		    && chooser->priv->image_width == 0) {
-			printf ("initial setting of an image.  no scaling\n");
+			d (printf ("initial setting of an image.  no scaling\n"));
 			scale = 1.0;
 		}
 		else if (chooser->priv->image_height < new_height
 			 || chooser->priv->image_width < new_width) {
 			/* we need to scale down */
-			printf ("we need to scale down\n");
+			d (printf ("we need to scale down\n"));
 			if (new_height > new_width)
 				scale = (gfloat)chooser->priv->image_height / new_height;
 			else
@@ -262,14 +264,14 @@ set_image_from_data (EImageChooser *chooser,
 		}
 		else {
 			/* we need to scale up */
-			printf ("we need to scale up\n");
+			d (printf ("we need to scale up\n"));
 			if (new_height > new_width)
 				scale = (gfloat)new_height / chooser->priv->image_height;
 			else
 				scale = (gfloat)new_width / chooser->priv->image_width;
 		}
 
-		printf ("scale = %g\n", scale);
+		d (printf ("scale = %g\n", scale));
 
 		if (scale == 1.0) {
 			gtk_image_set_from_pixbuf (GTK_IMAGE (chooser->priv->image), pixbuf);
@@ -283,7 +285,7 @@ set_image_from_data (EImageChooser *chooser,
 			new_width = MIN (new_width, chooser->priv->image_width);
 			new_height = MIN (new_height, chooser->priv->image_height);
 
-			printf ("new scaled dimensions = (%d,%d)\n", new_width, new_height);
+			d (printf ("new scaled dimensions = (%d,%d)\n", new_width, new_height));
 
 			scaled = e_icon_factory_pixbuf_scale (pixbuf, new_width, new_height);
 
@@ -418,7 +420,8 @@ image_drag_data_received_cb (GtkWidget *widget,
 			}
 		}
 
-		g_free (buf);
+		if (!handled)
+			g_free (buf);
 		g_free (uri);
 
 		if (error) {



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