headerbar: Null-check boxes when removing window controls

Prevent a crash when show-title-buttons value changes to FALSE during
destruction.
This commit is contained in:
Alexander Mikhaylenko 2021-02-08 18:46:35 +05:00
parent 319755662f
commit cf61d96188

View File

@ -743,13 +743,13 @@ gtk_header_bar_set_show_title_buttons (GtkHeaderBar *bar,
create_window_controls (bar); create_window_controls (bar);
else else
{ {
if (bar->start_window_controls) if (bar->start_box && bar->start_window_controls)
{ {
gtk_box_remove (GTK_BOX (bar->start_box), bar->start_window_controls); gtk_box_remove (GTK_BOX (bar->start_box), bar->start_window_controls);
bar->start_window_controls = NULL; bar->start_window_controls = NULL;
} }
if (ar->end_window_controls) if (bar->end_box && bar->end_window_controls)
{ {
gtk_box_remove (GTK_BOX (bar->end_box), bar->end_window_controls); gtk_box_remove (GTK_BOX (bar->end_box), bar->end_window_controls);
bar->end_window_controls = NULL; bar->end_window_controls = NULL;