mirror of
https://gitlab.gnome.org/GNOME/gimp.git
synced 2025-07-03 17:33:25 +00:00
app: better handle bogus file names.
When a plug-in enters a bogus file name such as "Untitled.xcd" as URI, g_file_is_native() returns FALSE. So when saving such file, core code tries to mount a remote volume and fails (of course), without even opening the file dialog. This change is an attempt to detect such cases beforehand and not even try to save it (just open the file dialog directly; the file name is still useful as default proposed file name, as this part is actually valid). Actually remote files will have a valid URI anyway (something with a valid scheme, such as https:// or whatever other scheme). As side fix, I am adding a missing space to the error which I got.
This commit is contained in:
parent
4f1d0fb53b
commit
473f0b49ef
2 changed files with 22 additions and 4 deletions
|
@ -258,9 +258,27 @@ file_save_cmd_callback (GimpAction *action,
|
|||
! GIMP_GUI_CONFIG (image->gimp->config)->trust_dirty_flag) ||
|
||||
file == NULL)
|
||||
{
|
||||
GimpPlugInProcedure *save_proc = gimp_image_get_save_proc (image);
|
||||
GimpPlugInProcedure *save_proc = gimp_image_get_save_proc (image);
|
||||
gboolean valid_file = FALSE;
|
||||
|
||||
if (file && ! save_proc)
|
||||
if (file)
|
||||
{
|
||||
gchar *uri = g_file_get_uri (file);
|
||||
|
||||
/* Non-valid URI (such as "Untitled.xcd" without a scheme) are
|
||||
* considered non-native by GLib and will trigger remote file code
|
||||
* path in file_save_dialog_save_image(), eventually failing with
|
||||
* a weird error. When we encounter such non-valid URI, we just
|
||||
* consider that the file was entered manually with a bogus name
|
||||
* (possibly by some script or plug-in) and we fall through
|
||||
* directly to showing the file dialog. The file name will still
|
||||
* be useful as default file name.
|
||||
*/
|
||||
valid_file = g_uri_is_valid (uri, G_URI_FLAGS_NONE, NULL);
|
||||
g_free (uri);
|
||||
}
|
||||
|
||||
if (valid_file && ! save_proc)
|
||||
{
|
||||
save_proc =
|
||||
gimp_plug_in_manager_file_procedure_find (image->gimp->plug_in_manager,
|
||||
|
@ -268,7 +286,7 @@ file_save_cmd_callback (GimpAction *action,
|
|||
file, NULL);
|
||||
}
|
||||
|
||||
if (file && save_proc)
|
||||
if (valid_file && save_proc)
|
||||
{
|
||||
saved = file_save_dialog_save_image (GIMP_PROGRESS (display),
|
||||
gimp, image, file,
|
||||
|
|
|
@ -159,7 +159,7 @@ file_save (Gimp *gimp,
|
|||
{
|
||||
if (my_error)
|
||||
{
|
||||
g_printerr ("%s: mounting remote volume failed, trying to upload"
|
||||
g_printerr ("%s: mounting remote volume failed, trying to upload "
|
||||
"the file: %s\n",
|
||||
G_STRFUNC, my_error->message);
|
||||
g_clear_error (&my_error);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue