[gtk/wip/baedert/for-master: 180/180] text: Avoid a crash
- From: Timm Bäder <baedert src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtk/wip/baedert/for-master: 180/180] text: Avoid a crash
- Date: Fri, 16 Oct 2020 19:58:53 +0000 (UTC)
commit 36a5304b24f447c2e4b6309b68890a0c206b5445
Author: Timm Bäder <mail baedert org>
Date: Fri Oct 16 21:55:37 2020 +0200
text: Avoid a crash
Calculate the "was previous focus in a child widget" condition before
chaining up into grab_focus, to a void that unreffing the prev_focus
widget.
gtk/gtktext.c | 5 +++--
1 file changed, 3 insertions(+), 2 deletions(-)
---
diff --git a/gtk/gtktext.c b/gtk/gtktext.c
index 26bf27eeb5..44958ae29f 100644
--- a/gtk/gtktext.c
+++ b/gtk/gtktext.c
@@ -3223,14 +3223,15 @@ gtk_text_grab_focus (GtkWidget *widget)
GtkTextPrivate *priv = gtk_text_get_instance_private (self);
gboolean select_on_focus;
GtkWidget *prev_focus;
+ gboolean prev_focus_was_child;
prev_focus = gtk_root_get_focus (gtk_widget_get_root (widget));
+ prev_focus_was_child = prev_focus && gtk_widget_is_ancestor (prev_focus, widget);
if (!GTK_WIDGET_CLASS (gtk_text_parent_class)->grab_focus (GTK_WIDGET (self)))
return FALSE;
- if (priv->editable && !priv->in_click &&
- !(prev_focus && gtk_widget_is_ancestor (prev_focus, widget)))
+ if (priv->editable && !priv->in_click && !prev_focus_was_child)
{
g_object_get (gtk_widget_get_settings (widget),
"gtk-entry-select-on-focus",
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]