Skip to content

Commit d554a47

Browse files
committed
A few null checks
1 parent bc55028 commit d554a47

File tree

3 files changed

+19
-14
lines changed

3 files changed

+19
-14
lines changed

lib/Models/Window.vala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ public class He.Window : Gtk.Window {
2828
/**
2929
* The parent window of this window. If this is null, then this is a top-level window.
3030
*/
31-
private new Gtk.Window ? _parent;
31+
private new Gtk.Window ? _parent = null;
3232
public new Gtk.Window ? parent {
3333
get {
3434
return this.get_transient_for ();

lib/Widgets/Chip.vala

Lines changed: 14 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -46,18 +46,21 @@ public class He.Chip : Gtk.ToggleButton, Gtk.Actionable {
4646
this.add_css_class ("chip");
4747

4848
chip_box = new He.ButtonContent ();
49-
chip_box.get_first_child ().get_first_child ().visible = false;
50-
chip_box.icon = "";
5149

52-
notify["active"].connect (() => {
53-
if (this.active) {
54-
chip_box.get_first_child ().get_first_child ().visible = true;
55-
chip_box.icon = "emblem-default-symbolic";
56-
} else {
57-
chip_box.get_first_child ().get_first_child ().visible = false;
58-
chip_box.icon = "";
59-
}
60-
});
50+
if (chip_box.get_first_child ().get_first_child () != null) {
51+
chip_box.get_first_child ().get_first_child ().visible = false;
52+
chip_box.icon = "";
53+
54+
notify["active"].connect (() => {
55+
if (this.active) {
56+
chip_box.get_first_child ().get_first_child ().visible = true;
57+
chip_box.icon = "emblem-default-symbolic";
58+
} else {
59+
chip_box.get_first_child ().get_first_child ().visible = false;
60+
chip_box.icon = "";
61+
}
62+
});
63+
}
6164

6265
chip_box.set_parent (this);
6366
}

lib/Widgets/DatePicker.vala

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -117,8 +117,10 @@ private class He.CalendarWidget : He.Bin {
117117
margin_start = 18,
118118
tooltip_text = _("Select Month")
119119
};
120-
((Gtk.Label) header_label.get_first_child()).set_width_chars(14);
121-
((Gtk.Label) header_label.get_first_child()).add_css_class("cb-title");
120+
if (((Gtk.Label) header_label.get_first_child()) != null) {
121+
((Gtk.Label) header_label.get_first_child()).set_width_chars(14);
122+
((Gtk.Label) header_label.get_first_child()).add_css_class("cb-title");
123+
}
122124
header_label.add_css_class("flat");
123125
header_label.clicked.connect(() => toggle_view());
124126

0 commit comments

Comments
 (0)