diff options
-rw-r--r-- | gsystem-file-utils.c | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/gsystem-file-utils.c b/gsystem-file-utils.c index f70239c..6291027 100644 --- a/gsystem-file-utils.c +++ b/gsystem-file-utils.c @@ -743,6 +743,8 @@ gs_file_linkcopy_sync_data (GFile *src, return linkcopy_internal (src, dest, flags, TRUE, cancellable, error); } +G_LOCK_DEFINE_STATIC (pathname_cache); + /** * gs_file_get_path_cached: * @@ -758,6 +760,8 @@ gs_file_get_path_cached (GFile *file) if (G_UNLIKELY (_file_path_quark) == 0) _file_path_quark = g_quark_from_static_string ("gsystem-file-path"); + G_LOCK (pathname_cache); + path = g_object_get_qdata ((GObject*)file, _file_path_quark); if (!path) { @@ -765,6 +769,9 @@ gs_file_get_path_cached (GFile *file) g_assert (path != NULL); g_object_set_qdata_full ((GObject*)file, _file_path_quark, (char*)path, (GDestroyNotify)g_free); } + + G_UNLOCK (pathname_cache); + return path; } @@ -783,12 +790,17 @@ gs_file_get_basename_cached (GFile *file) if (G_UNLIKELY (_file_name_quark) == 0) _file_name_quark = g_quark_from_static_string ("gsystem-file-name"); + G_LOCK (pathname_cache); + name = g_object_get_qdata ((GObject*)file, _file_name_quark); if (!name) { name = g_file_get_basename (file); g_object_set_qdata_full ((GObject*)file, _file_name_quark, (char*)name, (GDestroyNotify)g_free); } + + G_UNLOCK (pathname_cache); + return name; } |