gdesktopappinfo: Call g_file_get_path() on demand

Rather than always calling out to g_file_get_path() (which
might block, whatever the documentation might say), postpone
the call until we actually need it.

https://bugzilla.gnome.org/show_bug.cgi?id=708753
This commit is contained in:
Bastien Nocera 2013-09-25 16:14:17 +02:00 committed by Alexander Larsson
parent 458c1c0f16
commit 2d8e5ef81e

View File

@ -869,11 +869,10 @@ expand_macro_single (char macro, char *uri)
{ {
GFile *file; GFile *file;
char *result = NULL; char *result = NULL;
char *path, *name; char *path = NULL;
char *name;
file = g_file_new_for_uri (uri); file = g_file_new_for_uri (uri);
path = g_file_get_path (file);
g_object_unref (file);
switch (macro) switch (macro)
{ {
@ -883,11 +882,13 @@ expand_macro_single (char macro, char *uri)
break; break;
case 'f': case 'f':
case 'F': case 'F':
path = g_file_get_path (file);
if (path) if (path)
result = g_shell_quote (path); result = g_shell_quote (path);
break; break;
case 'd': case 'd':
case 'D': case 'D':
path = g_file_get_path (file);
if (path) if (path)
{ {
name = g_path_get_dirname (path); name = g_path_get_dirname (path);
@ -897,6 +898,7 @@ expand_macro_single (char macro, char *uri)
break; break;
case 'n': case 'n':
case 'N': case 'N':
path = g_file_get_path (file);
if (path) if (path)
{ {
name = g_path_get_basename (path); name = g_path_get_basename (path);
@ -906,6 +908,7 @@ expand_macro_single (char macro, char *uri)
break; break;
} }
g_object_unref (file);
g_free (path); g_free (path);
return result; return result;