Skip to content

Commit

Permalink
Check if Granite.accel_to_string returns null (#463)
Browse files Browse the repository at this point in the history
Co-authored-by: Jeremy Wootten <[email protected]>
  • Loading branch information
lenemter and Jeremy Wootten authored Aug 17, 2023
1 parent 9536667 commit a66bb8a
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 3 deletions.
7 changes: 6 additions & 1 deletion src/Widgets/Shortcuts/CustomShortcutListBox.vala
Original file line number Diff line number Diff line change
Expand Up @@ -421,7 +421,12 @@ class Pantheon.Keyboard.Shortcuts.CustomShortcutListBox : Gtk.ListBox, ShortcutD
}

private void build_keycap_grid (string value_string, ref Gtk.Grid grid) {
var accels = Granite.accel_to_string (value_string).split (" + ");
var accels_string = Granite.accel_to_string (value_string);

string[] accels = {};
if (accels_string != null) {
accels = accels_string.split (" + ");
}
foreach (unowned Gtk.Widget child in grid.get_children ()) {
child.destroy ();
};
Expand Down
10 changes: 8 additions & 2 deletions src/Widgets/Shortcuts/ShortcutListBox.vala
Original file line number Diff line number Diff line change
Expand Up @@ -323,12 +323,18 @@ private class Pantheon.Keyboard.Shortcuts.ShortcutListBox : Gtk.ListBox, Shortcu
if (key_value.is_of_type (VariantType.ARRAY)) {
var key_value_strv = key_value.get_strv ();
if (key_value_strv.length > 0 && key_value_strv[0] != "") {
accels = Granite.accel_to_string (key_value_strv[0]).split (" + ");
var accels_string = Granite.accel_to_string (key_value_strv[0]);
if (accels_string != null) {
accels = accels_string.split (" + ");
}
}
} else {
var value_string = key_value.dup_string ();
if (value_string != "") {
accels = Granite.accel_to_string (value_string).split (" + ");
var accels_string = Granite.accel_to_string (value_string);
if (accels_string != null) {
accels = accels_string.split (" + ");
}
}
}

Expand Down

0 comments on commit a66bb8a

Please sign in to comment.