From 805e7aec15c027837c1baf3912b55a635c04b1e0 Mon Sep 17 00:00:00 2001 From: Felipe Borges Date: Tue, 25 May 2021 16:56:09 +0200 Subject: nautilus-previewer: Only launch previewer when file URI changes There's a race condition for when Nautilus checks for Sushi's "Visible" property and decides whether a selection change should update the previewed file. By avoiding calling Sushi when the selected file is the same as the last one previewed, we can workaround the race condition. Fixes #1823 --- src/nautilus-previewer.c | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/src/nautilus-previewer.c b/src/nautilus-previewer.c index 66074ab93..4ab2e2d02 100644 --- a/src/nautilus-previewer.c +++ b/src/nautilus-previewer.c @@ -38,6 +38,7 @@ #define PREVIEWER_DBUS_PATH "/org/gnome/NautilusPreviewer" static GDBusProxy *previewer_v2_proxy = NULL; +static char *current_file_uri = NULL; static gboolean ensure_previewer_v2_proxy (void) @@ -88,6 +89,16 @@ nautilus_previewer_call_show_file (const gchar *uri, guint xid, gboolean close_if_already_visible) { + + if (current_file_uri != NULL && g_strcmp0 (current_file_uri, uri) == 0) + { + g_free (current_file_uri); + current_file_uri = NULL; + + return; + } + + current_file_uri = g_strdup (uri); if (!ensure_previewer_v2_proxy ()) { return; -- cgit v1.2.1