[gnome-usage] window: Null-check a variable before using it



commit 37f467f57b3bcc92297613311bcf741b753ce8ab
Author: Adrien Plazas <kekun plazas laposte net>
Date:   Fri Dec 3 11:53:15 2021 +0100

    window: Null-check a variable before using it
    
    This avoids a compilation warning.

 src/window.vala | 7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)
---
diff --git a/src/window.vala b/src/window.vala
index f565d40..6fb1211 100644
--- a/src/window.vala
+++ b/src/window.vala
@@ -121,8 +121,13 @@ namespace Usage {
 
         [GtkCallback]
         private void on_performance_search_button_toggled () {
+            var application = GLib.Application.get_default() as Application;
+
+            if (application == null)
+                return;
+
             /* TODO: Implement a saner way of toggling this mode. */
-            ((PerformanceView) (GLib.Application.get_default() as 
Application).get_window().get_views()[Views.PERFORMANCE]).set_search_mode(performance_search_button.active);
+            ((PerformanceView) 
application.get_window().get_views()[Views.PERFORMANCE]).set_search_mode(performance_search_button.active);
         }
 
         [GtkCallback]


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