# HG changeset patch # User Marcus Lundblad # Date 1228243581 0 # Node ID c31be282935db4f3c6c3716ccf995d178f25ee85 # Parent f59b9bfba784fdebd346d8105f0142b502806c59 When adding custom smiley without a previous filename (which is the case when adding a received smiley using the context menu, at which point there is only a pixbuf) create the storing dir if doesn't yet exists, since we need to dump the generated image there before calling purpl_smiley_create_from_file Closes #6623 diff -r f59b9bfba784 -r c31be282935d pidgin/gtksmiley.c --- a/pidgin/gtksmiley.c Tue Dec 02 15:58:39 2008 +0000 +++ b/pidgin/gtksmiley.c Tue Dec 02 18:46:21 2008 +0000 @@ -272,11 +272,25 @@ gchar *buffer = NULL; gsize size = 0; gchar *filename; + const gchar *dirname = purple_smileys_get_storing_dir(); + + /* since this may be called before purple_smiley_new_* has ever been + called, we create the storing dir, if it doesn't exist yet, to be + able to save the pixbuf before adding the smiley */ + if (!g_file_test(dirname, G_FILE_TEST_IS_DIR)) { + purple_debug_info("gtksmiley", "Creating smileys directory.\n"); + if (g_mkdir(dirname, S_IRUSR | S_IWUSR | S_IXUSR) < 0) { + purple_debug_error("gtksmiley", + "Unable to create directory %s: %s\n", + dirname, g_strerror(errno)); + } + } + gdk_pixbuf_save_to_buffer(s->custom_pixbuf, &buffer, &size, "png", NULL, "compression", "9", NULL, NULL); filename = purple_util_get_image_filename(buffer, size); - s->filename = g_build_filename(purple_smileys_get_storing_dir(), filename, NULL); + s->filename = g_build_filename(dirname, filename, NULL); purple_util_write_data_to_file_absolute(s->filename, buffer, size); g_free(filename); g_free(buffer);