File thunar-bugfixes.patch of Package thunar
diff -ur old/Thunar-1.6.10/thunar/thunar-file.c new/Thunar-1.6.10/thunar/thunar-file.c
--- old/Thunar-1.6.10/thunar/thunar-file.c 2015-05-22 15:25:36.000000000 +0200
+++ new/Thunar-1.6.10/thunar/thunar-file.c 2017-02-23 06:44:06.968364077 +0100
@@ -121,6 +121,7 @@
G_LOCK_DEFINE_STATIC (file_cache_mutex);
G_LOCK_DEFINE_STATIC (file_content_type_mutex);
+G_LOCK_DEFINE_STATIC (file_rename_mutex);
@@ -220,6 +221,22 @@
G_IMPLEMENT_INTERFACE (THUNARX_TYPE_FILE_INFO, thunar_file_info_init))
+static GWeakRef*
+weak_ref_new (GObject *obj)
+{
+ GWeakRef *ref;
+ ref = g_slice_new (GWeakRef);
+ g_weak_ref_init (ref, obj);
+ return ref;
+}
+
+static void
+weak_ref_free (GWeakRef *ref)
+{
+ g_weak_ref_clear (ref);
+ g_slice_free (GWeakRef, ref);
+}
+
#ifdef G_ENABLE_DEBUG
#ifdef HAVE_ATEXIT
@@ -235,7 +252,7 @@
gchar *uri;
uri = g_file_get_uri (key);
- g_print ("--> %s (%u)\n", uri, G_OBJECT (value)->ref_count);
+ g_print ("--> %s\n", uri);
if (G_OBJECT (key)->ref_count > 2)
g_print (" GFile (%u)\n", G_OBJECT (key)->ref_count - 2);
g_free (uri);
@@ -277,7 +294,7 @@
gchar *name;
name = g_file_get_parse_name (G_FILE (gfile));
- g_print (" %s (%u)\n", name, G_OBJECT (value)->ref_count);
+ g_print (" %s\n", name);
g_free (name);
}
@@ -728,7 +745,9 @@
g_object_unref (previous_file);
/* insert the new entry */
- g_hash_table_insert (file_cache, g_object_ref (file->gfile), file);
+ g_hash_table_insert (file_cache,
+ g_object_ref (file->gfile),
+ weak_ref_new (G_OBJECT (file)));
G_UNLOCK (file_cache_mutex);
}
@@ -780,7 +799,9 @@
/* the event occurred for the monitored ThunarFile */
if (event_type == G_FILE_MONITOR_EVENT_MOVED)
{
+ G_LOCK (file_rename_mutex);
thunar_file_monitor_moved (file, other_path);
+ G_UNLOCK (file_rename_mutex);
return;
}
@@ -795,13 +816,18 @@
if (event_type == G_FILE_MONITOR_EVENT_MOVED)
{
/* reload the target file if cached */
+ if (other_path == NULL)
+ return;
+
+ G_LOCK (file_rename_mutex);
+
other_file = thunar_file_cache_lookup (other_path);
if (other_file)
thunar_file_reload (other_file);
else
other_file = thunar_file_get (other_path, NULL);
- if (!other_file)
+ if (other_file == NULL)
return;
/* notify the thumbnail cache that we can now also move the thumbnail */
@@ -811,13 +837,14 @@
thunar_file_reload_parent (other_file);
g_object_unref (other_file);
+
+ G_UNLOCK (file_rename_mutex);
}
return;
}
}
-
static void
thunar_file_watch_destroyed (gpointer data)
{
@@ -1113,11 +1140,9 @@
/* insert the file into the cache */
G_LOCK (file_cache_mutex);
-#ifdef G_ENABLE_DEBUG
- /* check if there is no instance created in the meantime */
- _thunar_assert (g_hash_table_lookup (file_cache, file->gfile) == NULL);
-#endif
- g_hash_table_insert (file_cache, g_object_ref (file->gfile), file);
+ g_hash_table_insert (file_cache,
+ g_object_ref (file->gfile),
+ weak_ref_new (G_OBJECT (file)));
G_UNLOCK (file_cache_mutex);
/* pass the loaded file and possible errors to the return function */
@@ -1239,7 +1264,9 @@
G_LOCK (file_cache_mutex);
/* insert the file into the cache */
- g_hash_table_insert (file_cache, g_object_ref (file->gfile), file);
+ g_hash_table_insert (file_cache,
+ g_object_ref (file->gfile),
+ weak_ref_new (G_OBJECT (file)));
/* done inserting in the cache */
G_UNLOCK (file_cache_mutex);
@@ -1316,7 +1343,9 @@
G_LOCK (file_cache_mutex);
/* insert the file into the cache */
- g_hash_table_insert (file_cache, g_object_ref (file->gfile), file);
+ g_hash_table_insert (file_cache,
+ g_object_ref (file->gfile),
+ weak_ref_new (G_OBJECT (file)));
/* done inserting in the cache */
G_UNLOCK (file_cache_mutex);
@@ -1926,6 +1955,7 @@
}
else
{
+ G_LOCK (file_rename_mutex);
/* try to rename the file */
renamed_file = g_file_set_display_name (file->gfile, name, cancellable, error);
@@ -1942,11 +1972,12 @@
/* emit the file changed signal */
thunar_file_changed (file);
}
-
+ G_UNLOCK (file_rename_mutex);
return TRUE;
}
else
{
+ G_UNLOCK (file_rename_mutex);
return FALSE;
}
}
@@ -3918,7 +3949,7 @@
gboolean
thunar_file_reload (ThunarFile *file)
{
- _thunar_return_if_fail (THUNAR_IS_FILE (file));
+ _thunar_return_val_if_fail (THUNAR_IS_FILE (file), FALSE);
/* clear file pxmap cache */
thunar_icon_factory_clear_pixmap_cache (file);
@@ -3957,6 +3988,28 @@
/**
+ * thunar_file_reload_idle_unref:
+ * @file : a #ThunarFile instance.
+ *
+ * Schedules a reload of the @file by calling thunar_file_reload
+ * when idle. When scheduled function returns @file object will be
+ * unreferenced.
+ *
+ **/
+void
+thunar_file_reload_idle_unref (ThunarFile *file)
+{
+ _thunar_return_if_fail (THUNAR_IS_FILE (file));
+
+ g_idle_add_full (G_PRIORITY_DEFAULT_IDLE,
+ (GSourceFunc) thunar_file_reload,
+ file,
+ (GDestroyNotify) g_object_unref);
+}
+
+
+
+/**
* thunar_file_destroy:
* @file : a #ThunarFile instance.
*
@@ -4085,6 +4138,7 @@
ThunarFile *
thunar_file_cache_lookup (const GFile *file)
{
+ GWeakRef *ref;
ThunarFile *cached_file;
_thunar_return_val_if_fail (G_IS_FILE (file), NULL);
@@ -4097,18 +4151,15 @@
file_cache = g_hash_table_new_full (g_file_hash,
(GEqualFunc) g_file_equal,
(GDestroyNotify) g_object_unref,
- NULL);
+ (GDestroyNotify) weak_ref_free);
}
- cached_file = g_hash_table_lookup (file_cache, file);
+ ref = g_hash_table_lookup (file_cache, file);
- if (cached_file != NULL)
- {
- /* take a reference to avoid too-early releases outside the
- * file_cache_mutex, resuling in destroyed files being used
- * in running code */
- g_object_ref (cached_file);
- }
+ if (ref == NULL)
+ cached_file = NULL;
+ else
+ cached_file = g_weak_ref_get (ref);
G_UNLOCK (file_cache_mutex);
diff -ur old/Thunar-1.6.10/thunar/thunar-file.h new/Thunar-1.6.10/thunar/thunar-file.h
--- old/Thunar-1.6.10/thunar/thunar-file.h 2015-05-22 15:25:36.000000000 +0200
+++ new/Thunar-1.6.10/thunar/thunar-file.h 2017-02-23 06:46:15.929328754 +0100
@@ -241,6 +241,7 @@
gboolean thunar_file_reload (ThunarFile *file);
void thunar_file_reload_idle (ThunarFile *file);
+void thunar_file_reload_idle_unref (ThunarFile *file);
void thunar_file_reload_parent (ThunarFile *file);
void thunar_file_destroy (ThunarFile *file);
diff -ur old/Thunar-1.6.10/thunar/thunar-folder.c new/Thunar-1.6.10/thunar/thunar-folder.c
--- old/Thunar-1.6.10/thunar/thunar-folder.c 2015-05-22 15:25:36.000000000 +0200
+++ new/Thunar-1.6.10/thunar/thunar-folder.c 2017-02-23 06:46:15.929328754 +0100
@@ -276,6 +276,9 @@
{
ThunarFolder *folder = THUNAR_FOLDER (object);
+ if (folder->corresponding_file)
+ thunar_file_unwatch (folder->corresponding_file);
+
/* disconnect from the ThunarFileMonitor instance */
g_signal_handlers_disconnect_matched (folder->file_monitor, G_SIGNAL_MATCH_DATA, 0, 0, NULL, NULL, folder);
g_object_unref (folder->file_monitor);
@@ -356,7 +359,11 @@
switch (prop_id)
{
case PROP_CORRESPONDING_FILE:
+ if (folder->corresponding_file)
+ thunar_file_unwatch (folder->corresponding_file);
folder->corresponding_file = g_value_dup_object (value);
+ if (folder->corresponding_file)
+ thunar_file_watch (folder->corresponding_file);
break;
case PROP_LOADING:
@@ -773,27 +780,30 @@
{
/* destroy the old file and update the new one */
thunar_file_destroy (lp->data);
- file = thunar_file_get(other_file, NULL);
- if (file != NULL && THUNAR_IS_FILE (file))
+ if (other_file != NULL)
{
- thunar_file_reload (file);
-
- /* if source and target folders are different, also tell
- the target folder to reload for the changes */
- if (thunar_file_has_parent (file))
+ file = thunar_file_get(other_file, NULL);
+ if (file != NULL && THUNAR_IS_FILE (file))
{
- other_parent = thunar_file_get_parent (file, NULL);
- if (other_parent &&
- !g_file_equal (thunar_file_get_file(folder->corresponding_file),
- thunar_file_get_file(other_parent)))
+ thunar_file_reload (file);
+
+ /* if source and target folders are different, also tell
+ the target folder to reload for the changes */
+ if (thunar_file_has_parent (file))
{
- thunar_file_reload (other_parent);
- g_object_unref (other_parent);
+ other_parent = thunar_file_get_parent (file, NULL);
+ if (other_parent &&
+ !g_file_equal (thunar_file_get_file(folder->corresponding_file),
+ thunar_file_get_file(other_parent)))
+ {
+ thunar_file_reload (other_parent);
+ g_object_unref (other_parent);
+ }
}
- }
- /* drop reference on the other file */
- g_object_unref (file);
+ /* drop reference on the other file */
+ g_object_unref (file);
+ }
}
/* reload the folder of the source file */
diff -ur old/Thunar-1.6.10/thunar/thunar-job.c new/Thunar-1.6.10/thunar/thunar-job.c
--- old/Thunar-1.6.10/thunar/thunar-job.c 2015-05-22 15:25:36.000000000 +0200
+++ new/Thunar-1.6.10/thunar/thunar-job.c 2017-02-23 06:49:04.278653070 +0100
@@ -578,8 +578,7 @@
file = thunar_file_cache_lookup (lp->data);
if (file != NULL)
{
- thunar_file_reload_idle (file);
- g_object_unref (file);
+ thunar_file_reload_idle_unref (file);
}
}
diff -ur old/Thunar-1.6.10/thunar/thunar-standard-view.c new/Thunar-1.6.10/thunar/thunar-standard-view.c
--- old/Thunar-1.6.10/thunar/thunar-standard-view.c 2015-05-22 15:25:36.000000000 +0200
+++ new/Thunar-1.6.10/thunar/thunar-standard-view.c 2017-02-23 06:49:04.278653070 +0100
@@ -2167,7 +2167,7 @@
GFile *path;
GFile *tmp;
- _thunar_return_if_fail (THUNAR_IS_FILE (directory));
+ _thunar_return_val_if_fail (THUNAR_IS_FILE (directory), NULL);
/* determine the path of the directory */
path = g_object_ref (thunar_file_get_file (directory));
diff -ur old/Thunar-1.6.10/thunar/thunar-window.c new/Thunar-1.6.10/thunar/thunar-window.c
--- old/Thunar-1.6.10/thunar/thunar-window.c 2015-05-22 15:25:36.000000000 +0200
+++ new/Thunar-1.6.10/thunar/thunar-window.c 2017-02-23 06:49:04.278653070 +0100
@@ -2759,7 +2759,6 @@
{
ThunarFile *file = NULL;
ThunarFile *current_directory = NULL;
- ThunarHistory *history = NULL;
GtkWidget *old_view;
GList *selected_files = NULL;
@@ -2779,9 +2778,6 @@
/* remember the file selection */
selected_files = thunar_g_file_list_copy (thunar_component_get_selected_files (THUNAR_COMPONENT (old_view)));
- /* get a copy of the history */
- history = thunar_standard_view_copy_history (THUNAR_STANDARD_VIEW (old_view));
-
/* update the UI (else GtkUIManager will crash on merging) */
gtk_ui_manager_ensure_update (window->ui_manager);
}
@@ -2822,10 +2818,6 @@
if (gtk_widget_get_visible (GTK_WIDGET (window)))
g_object_set (G_OBJECT (window->preferences), "last-view", g_type_name (window->view_type), NULL);
- /* use the copy of the old history if available */
- if (history != NULL)
- thunar_standard_view_set_history (THUNAR_STANDARD_VIEW (window->view), history);
-
/* release the file references */
if (G_UNLIKELY (file != NULL))
g_object_unref (G_OBJECT (file));