[gnome-boxes] machine: Add some null checks



commit b9b33ce157fca3e53e931c4c9817e66fb9a7bb95
Author: Zeeshan Ali (Khattak) <zeeshanak gnome org>
Date:   Thu Mar 5 13:42:28 2015 +0000

    machine: Add some null checks
    
    Ensure window actually exists before accesshing any of its API.
    
    This fixes the issue of tons of criticals on the console on exiting
    Boxes while a box is connected to.

 src/machine.vala |    4 ++++
 1 files changed, 4 insertions(+), 0 deletions(-)
---
diff --git a/src/machine.vala b/src/machine.vala
index 9dae31d..c464e0b 100644
--- a/src/machine.vala
+++ b/src/machine.vala
@@ -80,6 +80,7 @@ private abstract class Boxes.Machine: Boxes.CollectionItem, Boxes.IPropertiesPro
             // state, we got to exit, as there is no way for the user
             // to progress in the vm display anymore
             if (display != null && !stay_on_display &&
+                window != null && // This being null would mean app is exitting & no window exists anymore
                 window.current_item == this &&
                 value != MachineState.RUNNING &&
                 window.ui_state != UIState.PROPERTIES &&
@@ -161,6 +162,9 @@ private abstract class Boxes.Machine: Boxes.CollectionItem, Boxes.IPropertiesPro
 
             disconnected_id = _display.disconnected.connect ((failed) => {
                 message (@"display $name disconnected");
+                if (window == null) // App exitting & no window exists anymore
+                    return;
+
                 if (window.ui_state == UIState.CREDS || window.ui_state == UIState.DISPLAY) {
                     if (!stay_on_display && window.current_item == this)
                         window.set_state (Boxes.UIState.COLLECTION);


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