summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNiels De Graef <nielsdegraef@gmail.com>2020-11-15 15:14:29 +0100
committerNiels De Graef <nielsdegraef@gmail.com>2020-11-15 15:14:29 +0100
commitee64d11e54caaa86477e8dad3ded08d1b8d9df84 (patch)
treefbcae038e31e9d2fc14e58bb1525a18b9c52f3a7
parent4ff2570e7a1435e1bf7ced849d5b90fa1223b892 (diff)
downloadgnome-contacts-ee64d11e54caaa86477e8dad3ded08d1b8d9df84.tar.gz
window: Add null-check for list_pane on startup
To implement search-as-you-type, we make sure to focus the search field if that wasn't the case already. However, if a user types something wile Contacts is still starting up, the UI hasn't finished by that time already, so that will lead us to dereferencing a NULL-pointer. To fix this nice and easy, let's to do a quick NULL-check before we try to focus anything. Fixes: https://gitlab.gnome.org/GNOME/gnome-contacts/-/issues/155
-rw-r--r--src/contacts-window.vala10
1 files changed, 8 insertions, 2 deletions
diff --git a/src/contacts-window.vala b/src/contacts-window.vala
index 10ee929..fc3f44e 100644
--- a/src/contacts-window.vala
+++ b/src/contacts-window.vala
@@ -448,7 +448,10 @@ public class Contacts.Window : Hdy.ApplicationWindow {
} else if (((event.keyval == Gdk.Key.s) ||
(event.keyval == Gdk.Key.f)) &&
((event.state & Gdk.ModifierType.CONTROL_MASK) != 0)) {
- Utils.grab_entry_focus_no_select (list_pane.filter_entry);
+ // Explicitly check if this.list_pane is already initialized,
+ // or we might crash at startup
+ if (this.list_pane != null && this.list_pane.filter_entry != null)
+ Utils.grab_entry_focus_no_select (this.list_pane.filter_entry);
} else if (event.length >= 1 &&
Gdk.keyval_to_unicode (event.keyval) != 0 &&
(event.state & Gdk.ModifierType.CONTROL_MASK) == 0 &&
@@ -456,7 +459,10 @@ public class Contacts.Window : Hdy.ApplicationWindow {
(event.keyval != Gdk.Key.Escape) &&
(event.keyval != Gdk.Key.Tab) &&
(event.keyval != Gdk.Key.BackSpace) ) {
- Utils.grab_entry_focus_no_select (list_pane.filter_entry);
+ // Explicitly check if this.list_pane is already initialized,
+ // or we might crash at startup
+ if (this.list_pane != null && this.list_pane.filter_entry != null)
+ Utils.grab_entry_focus_no_select (this.list_pane.filter_entry);
propagate_key_event (event);
}