[Spice-devel] [PATCH 4/4] Simplify spice_main_update_display_enabled()

Jonathon Jongsma jjongsma at redhat.com
Thu Jul 16 14:54:00 PDT 2015


When id is -1, we disable or enable all displays. To simplify the logic,
just call this function recursively in this case.
---
 src/channel-main.c | 13 +++++++------
 1 file changed, 7 insertions(+), 6 deletions(-)

diff --git a/src/channel-main.c b/src/channel-main.c
index 3b9d5b1..9383dbf 100644
--- a/src/channel-main.c
+++ b/src/channel-main.c
@@ -2784,15 +2784,16 @@ void spice_main_update_display_enabled(SpiceMainChannel *channel, int id, gboole
     if (id == -1) {
         gint i;
         for (i = 0; i < G_N_ELEMENTS(c->display); i++) {
-            c->display[i].display_state = display_state;
-        }
-    } else {
-        g_return_if_fail(id < G_N_ELEMENTS(c->display));
-        if (c->display[id].display_state == display_state)
+            spice_main_update_display_enabled(channel, i, enabled, update);
             return;
-        c->display[id].display_state = display_state;
+        }
     }
 
+    g_return_if_fail(id < G_N_ELEMENTS(c->display));
+    if (c->display[id].display_state == display_state)
+        return;
+    c->display[id].display_state = display_state;
+
     if (update)
         update_display_timer(channel, 1);
 }
-- 
2.1.0



More information about the Spice-devel mailing list