[gtk/wip/baedert/for-master: 48/54] windowcontrols: gtk_widget_get_root() can return NULL
- From: Timm Bäder <baedert src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtk/wip/baedert/for-master: 48/54] windowcontrols: gtk_widget_get_root() can return NULL
- Date: Tue, 13 Oct 2020 03:55:31 +0000 (UTC)
commit 64fd5fdc701faca34b7ef02d47f0e4c7c55b9fd4
Author: Timm Bäder <mail baedert org>
Date: Sun Oct 11 12:21:54 2020 +0200
windowcontrols: gtk_widget_get_root() can return NULL
gtk/gtkwindowcontrols.c | 35 ++++++++++++-----------------------
1 file changed, 12 insertions(+), 23 deletions(-)
---
diff --git a/gtk/gtkwindowcontrols.c b/gtk/gtkwindowcontrols.c
index b7e2acf17c..3411a5d13f 100644
--- a/gtk/gtkwindowcontrols.c
+++ b/gtk/gtkwindowcontrols.c
@@ -107,12 +107,12 @@ static char *
get_layout (GtkWindowControls *self)
{
GtkWidget *widget = GTK_WIDGET (self);
- GtkWidget *toplevel;
+ GtkRoot *root;
char *layout_desc, *layout_half;
char **tokens;
- toplevel = GTK_WIDGET (gtk_widget_get_root (widget));
- if (!GTK_IS_WINDOW (toplevel))
+ root = gtk_widget_get_root (widget);
+ if (!root || !GTK_IS_WINDOW (root))
return NULL;
if (self->decoration_layout)
@@ -221,7 +221,6 @@ static void
update_window_buttons (GtkWindowControls *self)
{
GtkWidget *widget = GTK_WIDGET (self);
- GtkWidget *toplevel;
char *layout;
char **tokens;
int i;
@@ -230,10 +229,11 @@ update_window_buttons (GtkWindowControls *self)
gboolean resizable;
gboolean deletable;
gboolean empty = TRUE;
+ GtkRoot *root;
GtkWindow *window = NULL;
- toplevel = GTK_WIDGET (gtk_widget_get_root (widget));
- if (!GTK_IS_WINDOW (toplevel))
+ root = gtk_widget_get_root (widget);
+ if (!root || !GTK_IS_WINDOW (root))
{
set_empty (self, TRUE);
@@ -242,23 +242,12 @@ update_window_buttons (GtkWindowControls *self)
clear_controls (self);
- if (GTK_IS_WINDOW (toplevel))
- {
- window = GTK_WINDOW (toplevel);
-
- is_sovereign_window = !gtk_window_get_modal (window) &&
- gtk_window_get_transient_for (window) == NULL;
- maximized = gtk_window_is_maximized (window);
- resizable = gtk_window_get_resizable (window);
- deletable = gtk_window_get_deletable (window);
- }
- else
- {
- is_sovereign_window = TRUE;
- maximized = FALSE;
- resizable = TRUE;
- deletable = TRUE;
- }
+ window = GTK_WINDOW (root);
+ is_sovereign_window = !gtk_window_get_modal (window) &&
+ gtk_window_get_transient_for (window) == NULL;
+ maximized = gtk_window_is_maximized (window);
+ resizable = gtk_window_get_resizable (window);
+ deletable = gtk_window_get_deletable (window);
layout = get_layout (self);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]