Re: gtk_grab_add() and key press events
- From: Owen Taylor <otaylor redhat com>
- To: Tim Janik <timj gtk org>
- Cc: Gtk+ Developers <gtk-devel-list gnome org>
- Subject: Re: gtk_grab_add() and key press events
- Date: 03 Feb 2001 14:27:56 -0500
Tim Janik <timj gtk org> writes:
> 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.
Hmmm, I don't see the problem.
widget->parent always references widget if non-NULL.
So, after:
> > + handled_event = !GTK_WIDGET_IS_SENSITIVE (widget) || gtk_widget_event (widget, event);
> > + tmp = widget->parent;
either tmp == NULL, or widget has a refcount > 1 and tmp is valid.
Unreferencing a widget with a refcount > 1 can't cause anything to
happen, so after:
> > + gtk_widget_unref (widget);
tmp is still either NULL or valid
> > + widget = tmp;
> > +
> > + if (!handled_event && widget)
> > + gtk_widget_ref (widget);
> > + else
> > + break;
And so this works fine.
Regards,
Owen
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]