Mercurial > pidgin.yaz
comparison pidgin/gtksmiley.c @ 32156:1693114a2655
applied changes from 6cf1aee8ac5e3c836af832eaf26ccedd611dc70b
through e802003adbf0be4496de3de8ac03b47c1e471d00
Original commit message:
Start looking at the GError parameter every time we call these functions:
- gdk_pixbuf_loader_write
- gdk_pixbuf_loader_close
- gdk_pixbuf_new_from_file
- gdk_pixbuf_new_from_file_at_size
- gdk_pixbuf_new_from_file_at_scale
There are times when gdkpixbuf returns a semi-invalid GdkPixbuf object and
also sets the GError. If this happens we want to discard and ignore the
GdkPixbuf object because it can cause problems. For example, calling
gdk_pixbuf_scale_simple() causes gdkpixbuf to rapidly consume memory in
an infinite loop. And that's bad.
This commit adds some helper functions to gtkutils.[c|h] that make it a
little easier to check the GError value. We should use them everywhere
we call any of the above functions.
author | Mark Doliner <mark@kingant.net> |
---|---|
date | Wed, 22 Jun 2011 07:09:42 +0000 |
parents | 917c597beb97 |
children | 904686722499 |
comparison
equal
deleted
inserted
replaced
32155:5ffd5582f5fe | 32156:1693114a2655 |
---|---|
330 if (!filename) | 330 if (!filename) |
331 return; | 331 return; |
332 | 332 |
333 g_free(s->filename); | 333 g_free(s->filename); |
334 s->filename = g_strdup(filename); | 334 s->filename = g_strdup(filename); |
335 pixbuf = gdk_pixbuf_new_from_file_at_scale(filename, 64, 64, FALSE, NULL); | 335 pixbuf = pidgin_pixbuf_new_from_file_at_scale(filename, 64, 64, FALSE); |
336 gtk_image_set_from_pixbuf(GTK_IMAGE(s->smiley_image), pixbuf); | 336 gtk_image_set_from_pixbuf(GTK_IMAGE(s->smiley_image), pixbuf); |
337 if (pixbuf) | 337 if (pixbuf) |
338 g_object_unref(G_OBJECT(pixbuf)); | 338 g_object_unref(G_OBJECT(pixbuf)); |
339 gtk_widget_grab_focus(s->smile); | 339 gtk_widget_grab_focus(s->smile); |
340 | 340 |
688 { | 688 { |
689 SmileyManager *dialog = user_data; | 689 SmileyManager *dialog = user_data; |
690 FILE *f; | 690 FILE *f; |
691 gchar *path; | 691 gchar *path; |
692 size_t wc; | 692 size_t wc; |
693 GError *err = NULL; | |
694 PidginSmiley *ps; | 693 PidginSmiley *ps; |
695 GdkPixbuf *image; | 694 GdkPixbuf *image; |
696 | 695 |
697 if ((error_message != NULL) || (len == 0)) { | 696 if ((error_message != NULL) || (len == 0)) { |
698 return; | 697 return; |
707 g_free(path); | 706 g_free(path); |
708 return; | 707 return; |
709 } | 708 } |
710 fclose(f); | 709 fclose(f); |
711 | 710 |
712 image = gdk_pixbuf_new_from_file(path, &err); | 711 image = pidgin_pixbuf_new_from_file(path); |
713 g_unlink(path); | 712 g_unlink(path); |
714 g_free(path); | 713 g_free(path); |
715 if (err) { | 714 if (!image) |
716 g_error_free(err); | 715 return; |
717 return; | |
718 } | |
719 | 716 |
720 ps = pidgin_smiley_edit(dialog->window, NULL); | 717 ps = pidgin_smiley_edit(dialog->window, NULL); |
721 pidgin_smiley_editor_set_image(ps, image); | 718 pidgin_smiley_editor_set_image(ps, image); |
722 pidgin_smiley_editor_set_data(ps, g_memdup(smileydata, len), len); | 719 pidgin_smiley_editor_set_data(ps, g_memdup(smileydata, len), len); |
723 } | 720 } |