[gnome-boxes/gnome-3-36] review-page: Apply all deferred property changes



commit 10c9fa33933d3eb8432d9639c01f8b1fbf76ba71
Author: Felipe Borges <felipeborges gnome org>
Date:   Wed Apr 15 13:25:36 2020 +0200

    review-page: Apply all deferred property changes
    
    That's a funny one: Boxes has a clever mechanism to avoid changing
    properties constantly (it can be UI blocking to change some of the
    properties, for example, the storage disk needs to be resized when
    the user changes the size on the GtkScale). The mechanism basically
    adds a timeout for properties to be applied later.
    
    Unfortunately, we can't shrink disks, therefore when it comes to
    storage size, we don't use the timeout mechanism mentioned above.
    This way, the properties need to be applied manually when the user
    is ready-to-create the VM.
    
    When adding the new VM Assistant, I didn't account for that, hence
    this uggly regression.
    
    cherry-picked from 227e2bac34445f04eb67db61e5763a5d0c93d34f
    
    Fixes #514
    Fixes #515

 src/assistant/review-page.vala | 9 ++++++++-
 1 file changed, 8 insertions(+), 1 deletion(-)
---
diff --git a/src/assistant/review-page.vala b/src/assistant/review-page.vala
index cb8c3307..5768b835 100644
--- a/src/assistant/review-page.vala
+++ b/src/assistant/review-page.vala
@@ -12,6 +12,7 @@
     private ToggleButton customize_button;
     [GtkChild]
     private Stack customization_stack;
+    private GLib.List<Boxes.Property> resource_properties;
 
     private Cancellable cancellable = new GLib.Cancellable ();
 
@@ -22,6 +23,8 @@ private void on_customize_button_toggled () {
     }
 
     public async void setup (VMCreator vm_creator) {
+        resource_properties = new GLib.List<Boxes.Property> ();
+
         try {
             artifact = yield vm_creator.create_vm (cancellable);
         } catch (IOError.CANCELLED cancel_error) { // We did this, so ignore!
@@ -70,7 +73,6 @@ public async void populate (LibvirtMachine machine) {
     }
 
     private void populate_customization_grid (LibvirtMachine machine) {
-        var resource_properties = new GLib.List<Boxes.Property> ();
         machine.properties.get_resources_properties (ref resource_properties);
 
         return_if_fail (resource_properties.length () > 0);
@@ -117,6 +119,11 @@ public override async void next () {
             disconnect (wait);
         }
 
+        // Let's apply all deferred changes in properties.
+        foreach (var property in resource_properties) {
+            property.flush ();
+        }
+
         done (artifact);
 
         cancellable.reset ();


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]