After an evaluation, GNOME has moved from Bugzilla to GitLab. Learn more about GitLab.
No new issues can be reported in GNOME Bugzilla anymore.
To report an issue in a GNOME project, go to GNOME GitLab.
Do not go to GNOME Gitlab for: Bluefish, Doxygen, GnuCash, GStreamer, java-gnome, LDTP, NetworkManager, Tomboy.
Bug 349966 - Evolution crashes on second save-as
Evolution crashes on second save-as
Status: RESOLVED FIXED
Product: evolution
Classification: Applications
Component: Mailer
2.8.x (obsolete)
Other Linux
: High critical
: ---
Assigned To: evolution-mail-maintainers
Evolution QA team
Depends on:
Blocks:
 
 
Reported: 2006-08-04 17:50 UTC by Daniel Gryniewicz
Modified: 2013-09-13 00:49 UTC
See Also:
GNOME target: ---
GNOME version: 2.15/2.16


Attachments
Backtrace (60.47 KB, text/plain)
2006-08-04 17:51 UTC, Daniel Gryniewicz
  Details
Proposed fix (60.94 KB, patch)
2006-08-04 17:52 UTC, Daniel Gryniewicz
none Details | Review
Actual proposed fix this time (568 bytes, patch)
2006-08-07 01:50 UTC, Daniel Gryniewicz
needs-work Details | Review
Switch to URIs everywhere (6.27 KB, patch)
2006-08-23 16:13 UTC, Daniel Gryniewicz
none Details | Review
new URI patch (23.41 KB, patch)
2006-08-24 20:19 UTC, Daniel Gryniewicz
accepted-commit_after_freeze Details | Review
new URI patch with key rename (22.94 KB, patch)
2006-08-25 18:09 UTC, Daniel Gryniewicz
none Details | Review
Here is the updated patch without the conflict. (23.73 KB, patch)
2006-10-16 17:04 UTC, Chenthill P
committed Details | Review

Description Daniel Gryniewicz 2006-08-04 17:50:12 UTC
When using save-as, the path used to save the message is stored in gconf.
The returned value is a URI, but gtk_file_chooser_set_current_folder() expects a
path, causing an assert in gtk+ the second time save-as is used.  Backtace will be attached, but the summary is:

Backtrace was generated from '/usr/bin/evolution-2.8'

Thread 1 (Thread 47563608585040 (LWP 12021))

  • #0 waitpid
    from /lib/libpthread.so.0
  • #1 gnome_gtk_module_info_get
    from /usr/lib/libgnomeui-2.so.0
  • #2 <signal handler called>
  • #3 IA__g_logv
    at gmessages.c line 493
  • #4 IA__g_log
    at gmessages.c line 517
  • #5 IA__g_return_if_fail_warning
  • #6 gnome_vfs_get_uri_from_local_path
    at gnome-vfs-utils.c line 794
  • #7 fs_module_init
    from /usr/lib64/gtk-2.0/2.10.0/filesystems/lib
  • #8 IA__gtk_file_system_filename_to_path
    at gtkfilesystem.c line 853
  • #9 IA__gtk_file_chooser_set_current_folder
    at gtkfilechooser.c line 675
  • #10 emu_get_save_filesel
    at em-utils.c line 419
  • #11 em_utils_save_messages
    at em-utils.c line 688

My solution is to put back the URI (which can also, take a path, tested by
setting the value in gconf) using gtk_file_chooser_set_current_folder_uri()
instead.  Patch attached.

Versions:
evolution 2.7.90
evolution-data-server 1.7.90.1
gtk+ 2.10.1
glib 2.12.1
Comment 1 Daniel Gryniewicz 2006-08-04 17:51:52 UTC
Created attachment 70212 [details]
Backtrace
Comment 2 Daniel Gryniewicz 2006-08-04 17:52:14 UTC
Created attachment 70213 [details] [review]
Proposed fix
Comment 3 Karsten Bräckelmann 2006-08-04 21:11:01 UTC
Daniel, unfortunately you attached the stacktrace twice, rather than the patch. Please attach the patch again, thanks. :)
Comment 4 Daniel Gryniewicz 2006-08-07 01:50:45 UTC
Created attachment 70348 [details] [review]
Actual proposed fix this time

Sorry about that.
Comment 5 Srinivasa Ragavan 2006-08-22 11:06:47 UTC
Daniel, I dont see the crash. From which view did u save? Also, I have only a path in gconf and Im surprised to see uri in gconf. If someone is storing a URI that has to fixed. AFAICS path is only storing in gconf. Let me know, if u found where we are storing URI.
Comment 6 Daniel Gryniewicz 2006-08-22 14:54:07 UTC
I didn't do anything special;  I just selected a number of messages in the message list (out of my junk folder, to be precise), and hit CTRL-C.

This would only be a problem with USE_GTKFILECHOOSER defined, for sure, but here's the offending code, I believe:

static void
emu_save_parts_response (GtkWidget *filesel, int response, GSList *parts)
{
        char *path = NULL;
        GSList *selected;
        if (response == GTK_RESPONSE_OK) {
#ifdef USE_GTKFILECHOOSER
                path = gtk_file_chooser_get_current_folder_uri (GTK_FILE_CHOOSER (filesel));       
#else 


Note that, with my change, either a URI or a filename works.  With the old code, a URI fails, but a filename works.  I believe this makes my change harmless, and allows saving files to non-local locations (like sftp).
Comment 7 Daniel Gryniewicz 2006-08-22 14:57:20 UTC
Sorry, CTRL-S.  Need more coffee this morning.
Comment 8 Srinivasa Ragavan 2006-08-22 16:38:29 UTC
Ha.. OK. Then that part was storing the URI, which wasnt known to me. OK. You have given  a nice point. With the support to store/open remote files, URI is the best candidate. We have to save/read uri every where. IIRC, calendar too uses this key. It could be great, if you can give patch to save/read uri every where. em-utils saves path at few places too, those have to be converted. Also the calendar/ too uses it just one place.


Thanks for the bug, patch, point :)
Comment 9 Daniel Gryniewicz 2006-08-23 03:00:59 UTC
I've been staring at this for a couple of hours now, and there's a problem.  em-utils mixes uris and paths, and the non USE_GTKFILECHOOSER is horribly broken.  I'm not sure that accessing non-file:// uris will work at this point, as the actual methods used for file access are g_ methods not gnome_vfs methods, and so only work on local files.  What I'm going to do at this point is prepare a patch that 1) removes the non USE_GTKFILECHOOSER case; 2) Uses uris consistantly for em-utils and anything else accessing that gconf key.  This will not get us remote file saving, but will get us closer to it, by using uris in general.

If you'd prefer that I swith the all the paths to local, non-uri paths, I can do that instead.
Comment 10 Srinivasa Ragavan 2006-08-23 04:27:26 UTC
Im OK to remove the NON_GTKFILECHOOSER part. I really wonder, do some one use that at all? Why was that introduced. Daniel, I guess, we can just store URI's every where. I dont see a problem. Please let me know, what problems you are facing. I implemented the remote support in 2.8. Ill be happy to fix any bug there.
Comment 11 Srinivasa Ragavan 2006-08-23 04:58:20 UTC
daniel: ping srag in #evolution if you need some help instead of bugzilla discussions (consumes time :)
Comment 12 Daniel Gryniewicz 2006-08-23 16:13:49 UTC
Created attachment 71472 [details] [review]
Switch to URIs everywhere

Here's what I believe to be the minimal fix for switching to URIs.  It removed the non-gtkchooser code, because there were referenced variables that were not being set in that code branch;  It changes all the dialogs to use URIs; It changes some functions to handle the fact that all strings returned by gtk_file_chooser_* and gnome_vfs_get_* are allcoated and need to be freed (thus removing some small memory leaks).

It turns out that the camel backend is using gnome-vfs, so some remote access should be possible.  However, in the save-all-attachments code, it specifically builds up local filenames.  That would have to be changed to handle URIs.

Finally, the test for popping up the overwrite dialog checks using g_access(), which only works on local files.  I believe there is a "confirm-overwrite" from gtk_file_chooser that could be used in place of this code, but I have not yet investigated it.

I've tested saving single and multiple emails, and saving single and multiple attachments, and they all work, with one exception that appears to be a bug in gtk_file_chooser:  If you turn on the ability to type in a path, when trying to save all attachments (ie, when the chooser is in folder mode), then clicking save does nothing in the case where you haven't typed anything into the path box.

I'm dang in #evolution, I'll ping you when we're both on together.
Comment 13 Srinivasa Ragavan 2006-08-23 19:09:55 UTC
Dang Awesome patch and observations. I really love this. Just few top level things

-  e-util/e-dialog-utils (Same as em-utils) and calendar/gui/dialogs/alarm-dialog.c uses the same key 

- "res" variable has to be gboolean in emu_can_save

- some formatting issue in emu_save_parts_response

- For Save all attachments, just pass the folder uri/filename. 

file_path = g_build_filename (uri, file_name, NULL);
if (!emu_file_check_local(file_path) || !g_file_test(file_path, (G_FILE_TEST_EXISTS)) || e_error_run(NULL, E_ERROR_ASK_FILE_EXISTS_OVERWRITE, file_name, NULL) == GTK_RESPONSE_OK)
			
	mail_save_part(part, file_path, NULL, NULL, FALSE);
else
	g_warning ("Could not save %s. File already exists", file_path);

should solve. Atm just the variable name is path, but it holds a URI received from file chooser.

Thanks for your great work Dang.
Comment 14 Daniel Gryniewicz 2006-08-24 20:19:10 UTC
Created attachment 71545 [details] [review]
new URI patch

Okay, here's take 2 on the URI patch.  What this patch does:
- Create a new gconf key for the calendar save location /apps/evolution/calendar/save_dir
- Create schemas for both mail/save_dir and calendar/save_dir
- Fix a memory leak for default path in the calendar save-as code
- Get rid of the non-USE_GTKFILECHOOSER code in e-utils/e-dialog-utils and mail/em-utils
    - It was broken in almost all cases (ie, not filling in local variables thate were later referenced in unconditional code)
- move emu_get_save_filesel to e-utils/e-dialog-utils and rename it e_file_get_save_filesel
- Make all file selecter creation use e_file_get_save_filesel in both places
- move emu_can_save to e_file_can_save, and consolidate all checks in both files to use that (and it's associated overwrite confirmation dialog)
- move emu_file_check_local to e_file_check_local, change it to use gnome_vfs instead of camel, and make all local file checks use it in both files.
- move emu_update_save_path and emu_get_save_path to e_file_update_save_path and e_file_get_save_path and fix all access to /apps/evolution/mail/save_dir to use those and to use URIs.

It would be nice if there was some clean gnome_vfs functions to check for file existance and writability by URI, but there aren't that I could find.  So, I'm still using the glib functions that act on local paths.

How I tested this:
I tested mail saving (both singly and in groups), attachment saving (both singly and in groups), and adding attachments to calendar entries.  All worked correctly, and all used the correct gconf keys.

String freeze break:
This breaks the string freeze in two ways: 1) It adds a schema for /apps/evolution/mail/save_dir, where one did not exist before; and 2) it adds /apps/evolution/calendar/save_dir and it's associated schema.

The reason for adding the new calendar save_dir is that the calendar code uses the older gnome_file_entry code, which does not work on URIs as far as I can tell.  Rather than converting it all to use gtk_file_chooser, I chose to let it save it's own path to gconf in local-path format, rather than URI.

If it's necessary, I can look into porting the calendar code to use gtk_file_chooser instead.  this would be more work and a bigger patch.
Comment 15 Srinivasa Ragavan 2006-08-25 08:07:25 UTC
Dang, the patch looks perfectly OK. But for some reason, the calendar doesnt remember the path, though, it is set there. Im not so keen on it atm. Can you request for a string freeze break to release-team/gnome-i18n ? 

The main point could be that, there is a key used without a schema.
Comment 16 Daniel Gryniewicz 2006-08-25 18:06:28 UTC
Adding attachments to email and appointments, as opposed to saving them, doesn't seem to use a saved directory.  Instead, it always opens up in the homedir.

I've submitted the string freeze request.  srag and I decided to rename the calendar save key, new patch attached.
Comment 17 Daniel Gryniewicz 2006-08-25 18:09:11 UTC
Created attachment 71610 [details] [review]
new URI patch with key rename

The same as the previous patch, except that the new gconf key is renamed from
/apps/evolution/calendar/save_dir
to
/apps/evolution/calendar/audio_dir
Comment 18 Srinivasa Ragavan 2006-09-12 05:33:00 UTC
Dan, we should commit it to head, when the branching is done.
Comment 19 André Klapper 2006-09-12 08:19:38 UTC
srini: if your last comment is a "accepted-commit_after_freeze", feel free to set the patch status accordingly. :-)
Comment 20 Srinivasa Ragavan 2006-09-19 09:25:25 UTC
Please commit to head once we branch.
Comment 21 Harish Krishnaswamy 2006-10-16 14:02:29 UTC
I'm afraid the patch does not apply clean on the HEAD anymore. 
Dan/Srini : Can you push in an updated patch pl. ?
Comment 22 Chenthill P 2006-10-16 17:04:43 UTC
Created attachment 74827 [details] [review]
Here is the updated patch without the conflict.
Comment 23 Srinivasa Ragavan 2006-11-27 18:51:26 UTC
Fixed to HEAD.