Author: benny
Date: 2006-07-28 22:35:03 +0000 (Fri, 28 Jul 2006)
New Revision: 22553
Modified:
thunar/trunk/ChangeLog
thunar/trunk/thunar/thunar-application.c
Log:
2006-07-29 Benedikt Meurer <[EMAIL PROTECTED]>
* thunar/thunar-application.c(thunar_application_collect_and_launch):
Always sanity check the list of paths when collecting files for a
copy or move operation, as applications might provide invalid URI
lists during a DnD operation.
Modified: thunar/trunk/ChangeLog
===================================================================
--- thunar/trunk/ChangeLog 2006-07-28 13:33:20 UTC (rev 22552)
+++ thunar/trunk/ChangeLog 2006-07-28 22:35:03 UTC (rev 22553)
@@ -1,3 +1,10 @@
+2006-07-29 Benedikt Meurer <[EMAIL PROTECTED]>
+
+ * thunar/thunar-application.c(thunar_application_collect_and_launch):
+ Always sanity check the list of paths when collecting files for a
+ copy or move operation, as applications might provide invalid URI
+ lists during a DnD operation.
+
2006-07-28 Benedikt Meurer <[EMAIL PROTECTED]>
* thunar/thunar-icon-factory.c(thunar_icon_factory_load_file_icon): Do
Modified: thunar/trunk/thunar/thunar-application.c
===================================================================
--- thunar/trunk/thunar/thunar-application.c 2006-07-28 13:33:20 UTC (rev
22552)
+++ thunar/trunk/thunar/thunar-application.c 2006-07-28 22:35:03 UTC (rev
22553)
@@ -22,6 +22,9 @@
#include <config.h>
#endif
+#ifdef HAVE_ERRNO_H
+#include <errno.h>
+#endif
#ifdef HAVE_MEMORY_H
#include <memory.h>
#endif
@@ -293,6 +296,7 @@
{
ThunarVfsInfo *info;
ThunarVfsPath *path;
+ GError *err = NULL;
GList *target_path_list = NULL;
GList *lp;
gchar *original_path;
@@ -303,47 +307,68 @@
return;
/* generate the target path list */
- for (lp = g_list_last (source_path_list); lp != NULL; lp = lp->prev)
+ for (lp = g_list_last (source_path_list); err == NULL && lp != NULL; lp =
lp->prev)
{
/* reset the path */
path = NULL;
- /* check if we're copying from a location in the trash */
- if (G_UNLIKELY (thunar_vfs_path_get_scheme (lp->data) ==
THUNAR_VFS_PATH_SCHEME_TRASH))
+ /* verify that we're not trying to collect a root node */
+ if (G_UNLIKELY (thunar_vfs_path_is_root (lp->data)))
{
- /* determine the info for the trashed resource */
- info = thunar_vfs_info_new_for_path (lp->data, NULL);
- if (G_LIKELY (info != NULL))
+ /* tell the user that we cannot perform the requested operation */
+ g_set_error (&err, G_FILE_ERROR, G_FILE_ERROR_INVAL, g_strerror
(EINVAL));
+ }
+ else
+ {
+ /* check if we're copying from a location in the trash */
+ if (G_UNLIKELY (thunar_vfs_path_get_scheme (lp->data) ==
THUNAR_VFS_PATH_SCHEME_TRASH))
{
- /* try to use the basename of the original path */
- original_path = thunar_vfs_info_get_metadata (info,
THUNAR_VFS_INFO_METADATA_TRASH_ORIGINAL_PATH, NULL);
- if (G_LIKELY (original_path != NULL))
+ /* determine the info for the trashed resource */
+ info = thunar_vfs_info_new_for_path (lp->data, NULL);
+ if (G_LIKELY (info != NULL))
{
- /* g_path_get_basename() may return '.' or '/' */
- original_name = g_path_get_basename (original_path);
- if (strcmp (original_name, ".") != 0 && strchr
(original_name, G_DIR_SEPARATOR) == NULL)
- path = thunar_vfs_path_relative (target_path,
original_name);
- g_free (original_name);
- g_free (original_path);
+ /* try to use the basename of the original path */
+ original_path = thunar_vfs_info_get_metadata (info,
THUNAR_VFS_INFO_METADATA_TRASH_ORIGINAL_PATH, NULL);
+ if (G_LIKELY (original_path != NULL))
+ {
+ /* g_path_get_basename() may return '.' or '/' */
+ original_name = g_path_get_basename (original_path);
+ if (strcmp (original_name, ".") != 0 && strchr
(original_name, G_DIR_SEPARATOR) == NULL)
+ path = thunar_vfs_path_relative (target_path,
original_name);
+ g_free (original_name);
+ g_free (original_path);
+ }
+
+ /* release the info */
+ thunar_vfs_info_unref (info);
}
+ }
- /* release the info */
- thunar_vfs_info_unref (info);
- }
+ /* fallback to the path's basename */
+ if (G_LIKELY (path == NULL))
+ path = thunar_vfs_path_relative (target_path,
thunar_vfs_path_get_name (lp->data));
+
+ /* add to the target path list */
+ target_path_list = g_list_prepend (target_path_list, path);
}
+ }
- /* fallback to the path's basename */
- if (G_LIKELY (path == NULL))
- path = thunar_vfs_path_relative (target_path, thunar_vfs_path_get_name
(lp->data));
+ /* check if we failed */
+ if (G_UNLIKELY (err != NULL))
+ {
+ /* display an error message to the user */
+ thunar_dialogs_show_error (parent, err, _("Failed to launch operation"));
- /* add to the target path list */
- target_path_list = g_list_prepend (target_path_list, path);
+ /* release the error */
+ g_error_free (err);
}
+ else
+ {
+ /* launch the operation */
+ thunar_application_launch (application, parent, icon_name, title,
launcher,
+ source_path_list, target_path_list,
new_files_closure);
+ }
- /* launch the operation */
- thunar_application_launch (application, parent, icon_name, title, launcher,
- source_path_list, target_path_list,
new_files_closure);
-
/* release the target path list */
thunar_vfs_path_list_free (target_path_list);
}
_______________________________________________
Xfce4-commits mailing list
[email protected]
http://foo-projects.org/mailman/listinfo/xfce4-commits