[gnome-contacts/bugfix/startup-crash] window: Add null-check for list_pane on startup
- From: Niels De Graef <nielsdg src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-contacts/bugfix/startup-crash] window: Add null-check for list_pane on startup
- Date: Sun, 15 Nov 2020 14:18:06 +0000 (UTC)
commit ee64d11e54caaa86477e8dad3ded08d1b8d9df84
Author: Niels De Graef <nielsdegraef gmail com>
Date: Sun Nov 15 15:14:29 2020 +0100
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
src/contacts-window.vala | 10 ++++++++--
1 file changed, 8 insertions(+), 2 deletions(-)
---
diff --git a/src/contacts-window.vala b/src/contacts-window.vala
index 10ee929b..fc3f44e1 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);
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]