Re: gtk_grab_add() and key press events



On 2 Feb 2001, Owen Taylor wrote:

> While working on one of the older GTK+ bugs:

>    /* Other events get propagated up the widget tree
>     *  so that parents can see the button and motion
>     *  events of the children.
>     */
> -  while (!handled_event && widget)
> +  if (!handled_event)
>      {
> -      GtkWidget *tmp;
> +      while (TRUE)
> +	{
> +	  GtkWidget *tmp;
> +	  
> +	  handled_event = !GTK_WIDGET_IS_SENSITIVE (widget) || gtk_widget_event (widget, event);
> +	  tmp = widget->parent;
> +	  gtk_widget_unref (widget);

when an event destroyed a widget and its parent and erroneously returns
FALSE, the below gtk_widget_ref (widget); might go to hell. granted,
the old code had the same problem, it just occoured to me.

>  
> -      gtk_widget_ref (widget);
> -      handled_event = !GTK_WIDGET_IS_SENSITIVE (widget) || gtk_widget_event (widget, event);
> -      tmp = widget->parent;
> -      gtk_widget_unref (widget);
> -      widget  = tmp;
> +	  widget = tmp;
> +	  
> +	  if (!handled_event && widget)
> +	    gtk_widget_ref (widget);
> +	  else
> +	    break;
> +	}
>      }
> +  else
> +    gtk_widget_unref (widget);
>  }


---
ciaoTJ





[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]