[virt-tools-list] [PATCH virt-viewer v3 04/10] ovirt-foreign-menu: Notify of new files even if nothing changed

Eduardo Lima (Etrunko) etrunko at redhat.com
Fri Jul 29 21:40:27 UTC 2016


When user presses the Refresh button in ISO dialog, the list is cleared, and
currently, the only way it is informed of the new list is by the notify signal.
The same applies when an error occurs while trying to change the current ISO.

Signed-off-by: Eduardo Lima (Etrunko) <etrunko at redhat.com>
---
 src/ovirt-foreign-menu.c | 43 +++++++++++++++----------------------------
 1 file changed, 15 insertions(+), 28 deletions(-)

diff --git a/src/ovirt-foreign-menu.c b/src/ovirt-foreign-menu.c
index 493ca47..8320552 100644
--- a/src/ovirt-foreign-menu.c
+++ b/src/ovirt-foreign-menu.c
@@ -375,22 +375,24 @@ static void updated_cdrom_cb(GObject *source_object,
         g_free(foreign_menu->priv->current_iso_name);
         foreign_menu->priv->current_iso_name = foreign_menu->priv->next_iso_name;
         foreign_menu->priv->next_iso_name = NULL;
-        g_object_notify(G_OBJECT(foreign_menu), "file");
-    } else {
-        /* Reset old state back as we were not successful in switching to
-         * the new ISO */
-        const char *current_file = foreign_menu->priv->current_iso_name;
-
-        if (error != NULL) {
-            g_warning("failed to update cdrom resource: %s", error->message);
-            g_clear_error(&error);
-        }
-        g_debug("setting OvirtCdrom:file back to '%s'",
-                current_file?current_file:NULL);
-        g_object_set(foreign_menu->priv->cdrom, "file", current_file, NULL);
+        goto end;
     }
 
+    /* Reset old state back as we were not successful in switching to
+     * the new ISO */
+    if (error != NULL) {
+        g_warning("failed to update cdrom resource: %s", error->message);
+        g_clear_error(&error);
+    }
+    g_debug("setting OvirtCdrom:file back to '%s'",
+            foreign_menu->priv->current_iso_name);
+    g_object_set(foreign_menu->priv->cdrom,
+                 "file", foreign_menu->priv->current_iso_name,
+                 NULL);
     g_clear_pointer(&foreign_menu->priv->next_iso_name, g_free);
+
+end:
+    g_object_notify(G_OBJECT(foreign_menu), "file");
 }
 
 
@@ -399,7 +401,6 @@ static void ovirt_foreign_menu_set_files(OvirtForeignMenu *menu,
 {
     GList *sorted_files = NULL;
     const GList *it;
-    GList *it2;
 
     for (it = files; it != NULL; it = it->next) {
         char *name;
@@ -416,20 +417,6 @@ static void ovirt_foreign_menu_set_files(OvirtForeignMenu *menu,
                                             (GCompareFunc)g_strcmp0);
     }
 
-    for (it = sorted_files, it2 = menu->priv->iso_names;
-         (it != NULL) && (it2 != NULL);
-         it = it->next, it2 = it2->next) {
-        if (g_strcmp0(it->data, it2->data) != 0) {
-            break;
-        }
-    }
-
-    if ((it == NULL) && (it2 == NULL)) {
-        /* sorted_files and menu->priv->files content was the same */
-        g_list_free_full(sorted_files, (GDestroyNotify)g_free);
-        return;
-    }
-
     g_list_free_full(menu->priv->iso_names, (GDestroyNotify)g_free);
     menu->priv->iso_names = sorted_files;
     g_object_notify(G_OBJECT(menu), "files");
-- 
2.7.4




More information about the virt-tools-list mailing list