From cb48f51b980f9b0c5f29e0485b611f5c8b602c67 Mon Sep 17 00:00:00 2001 From: Ondrej Holy Date: Fri, 17 Mar 2023 12:53:10 +0100 Subject: window: Initialize drag action for tab bar MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The `‘action’ may be used uninitialized` warning is shown during build currently. It can really happen that uninitialized value is used when dropping something else then the `GDK_TYPE_FILE_LIST` and `G_TYPE_STRING` on the tab bar. Let's initialize the action to prevent this. --- src/nautilus-window.c | 26 ++++++++++---------------- 1 file changed, 10 insertions(+), 16 deletions(-) diff --git a/src/nautilus-window.c b/src/nautilus-window.c index 30299b19d..9424f154d 100644 --- a/src/nautilus-window.c +++ b/src/nautilus-window.c @@ -1476,29 +1476,23 @@ extra_drag_value_cb (AdwTabBar *self, { NautilusWindowSlot *slot = NAUTILUS_WINDOW_SLOT (adw_tab_page_get_child (page)); g_autoptr (NautilusFile) file = nautilus_file_get (nautilus_window_slot_get_location (slot)); - GdkDragAction action; + GdkDragAction action = 0; - if (value == NULL) + if (value != NULL) { - action = 0; - } - else if (G_VALUE_HOLDS (value, GDK_TYPE_FILE_LIST)) - { - GSList *file_list = g_value_get_boxed (value); - - if (file_list == NULL) + if (G_VALUE_HOLDS (value, GDK_TYPE_FILE_LIST)) { - action = 0; + GSList *file_list = g_value_get_boxed (value); + if (file_list != NULL) + { + action = nautilus_dnd_get_preferred_action (file, G_FILE (file_list->data)); + } } - else + else if (G_VALUE_HOLDS (value, G_TYPE_STRING)) { - action = nautilus_dnd_get_preferred_action (file, G_FILE (file_list->data)); + action = GDK_ACTION_COPY; } } - else if (G_VALUE_HOLDS (value, G_TYPE_STRING)) - { - action = GDK_ACTION_COPY; - } /* We set the preferred action on the drop from the results of this function, * but since we don't have access to the GtkDropTarget, we can't get the preferred -- cgit v1.2.1