summaryrefslogtreecommitdiff
path: root/src/caja-main.c
diff options
context:
space:
mode:
authorStefano Karapetsas <[email protected]>2013-06-24 16:02:15 +0200
committerStefano Karapetsas <[email protected]>2013-06-24 16:02:15 +0200
commitd433b647391a28226bfd6fa5e5474c5bbc548c81 (patch)
treefc417e3690336b8d36f6d6c1226944dbf79e0011 /src/caja-main.c
parentd92c2754681b24ed5afcbb0d9458297e6101254e (diff)
downloadcaja-d433b647391a28226bfd6fa5e5474c5bbc548c81.tar.bz2
caja-d433b647391a28226bfd6fa5e5474c5bbc548c81.tar.xz
Fix URI management
Closes #134 (https://github.com/mate-desktop/mate-file-manager/issues/134)
Diffstat (limited to 'src/caja-main.c')
-rw-r--r--src/caja-main.c51
1 files changed, 30 insertions, 21 deletions
diff --git a/src/caja-main.c b/src/caja-main.c
index 1d74cd78..dcd9df11 100644
--- a/src/caja-main.c
+++ b/src/caja-main.c
@@ -329,11 +329,11 @@ main (int argc, char *argv[])
gboolean perform_self_check;
CajaApplication *application;
GOptionContext *context;
- GFile *file;
- GFileInfo *fileinfo;
- GAppInfo *appinfo;
- char *uri;
- char **uris;
+ GFile *file = NULL;
+ GFileInfo *fileinfo = NULL;
+ GAppInfo *appinfo = NULL;
+ char *uri = NULL;
+ char **uris = NULL;
GPtrArray *uris_array;
GError *error;
int i;
@@ -522,7 +522,6 @@ main (int argc, char *argv[])
else
{
/* Convert args to URIs */
- uris = NULL;
if (remaining != NULL)
{
uris_array = g_ptr_array_new ();
@@ -535,33 +534,43 @@ main (int argc, char *argv[])
if (uri)
{
fileinfo = g_file_query_info (file, G_FILE_ATTRIBUTE_STANDARD_TYPE, G_FILE_QUERY_INFO_NONE, NULL, NULL);
- if (g_file_info_get_file_type(fileinfo) == G_FILE_TYPE_DIRECTORY)
+ if (fileinfo && g_file_info_get_file_type(fileinfo) == G_FILE_TYPE_DIRECTORY)
{
g_ptr_array_add (uris_array, uri);
}
else
{
- g_object_unref (fileinfo);
+ if (fileinfo)
+ g_object_unref (fileinfo);
fileinfo = g_file_query_info (file, G_FILE_ATTRIBUTE_STANDARD_CONTENT_TYPE, G_FILE_QUERY_INFO_NONE, NULL, NULL);
- appinfo = g_app_info_get_default_for_type (g_file_info_get_content_type (fileinfo), TRUE);
- if (appinfo)
+ if (fileinfo)
{
- if (g_strcmp0 (g_app_info_get_executable (appinfo), "caja") != 0)
- {
- g_app_info_launch_default_for_uri (uri, NULL, NULL);
- }
- else
+ appinfo = g_app_info_get_default_for_type (g_file_info_get_content_type (fileinfo), TRUE);
+ if (appinfo)
{
- fprintf (stderr, _("caja: set erroneously as default application for '%s' content type.\n"),
- g_file_info_get_content_type (fileinfo));
+ if (g_strcmp0 (g_app_info_get_executable (appinfo), "caja") != 0)
+ {
+ g_app_info_launch_default_for_uri (uri, NULL, NULL);
+ }
+ else
+ {
+ fprintf (stderr, _("caja: set erroneously as default application for '%s' content type.\n"),
+ g_file_info_get_content_type (fileinfo));
+ }
+ g_object_unref (appinfo);
}
- g_object_unref (appinfo);
+ g_free (uri);
+ }
+ else
+ {
+ g_ptr_array_add (uris_array, uri);
}
- g_free (uri);
}
- g_object_unref (fileinfo);
+ if (fileinfo)
+ g_object_unref (fileinfo);
}
- g_object_unref (file);
+ if (file)
+ g_object_unref (file);
}
}
if (uris_array->len == 0)