Re: Gdk unexpected window destruction patch.

Tim Janik <> writes:

> hm, i'm not at all sure about this, but i'd actually imagine that your
> BadDrawable X errors could be fixed by adding a GtkPlug.destroy_event
> handler:

No, the BadDrawable errors may and will occur before the
DestroyNotify is received.

> and eventhough that is not vital for your case, this code portion in
> gtkmain.c should also be adapted:
>     case GDK_DELETE:
>       gtk_widget_ref (event_widget);
>       if (!gtk_widget_event (event_widget, event) &&
>           !GTK_OBJECT_DESTROYED (event_widget))
>         gtk_widget_destroy (event_widget);
>       gtk_widget_unref (event_widget);
>       break;
>     case GDK_DESTROY:
>       gtk_widget_ref (event_widget);
>       gtk_widget_event (event_widget, event);
>       if (!GTK_OBJECT_DESTROYED (event_widget))
>         gtk_widget_destroy (event_widget);
>       gtk_widget_unref (event_widget);
>       break;
> in a way that GDK_DESTROY behaves exactly like GDK_DELETE, so components can
> have a means to recover by returning TRUE from destroy_event, though
> that would change existing behaviour i doubt, tehre's actually code out there
> taht would trigger this (and then again, i've never been much in favour of
> that unconditioned widget destruction).

There is no way an application is going to recover and
prevent a window from being destroyed once it receives a GDK_DESTROY
on a window. It is already gone, kablooey, kaput. 

The best thing to do at this point is to destroy the
widget heirarchy and hope that cleans up things OK.
I suppose we could just unrealize, and not destroy,
but that would mean unconditionally setting the toplevel
!VISIBLE which is also yucky.

> void
> gdk_window_destroy_notify_new (GdkWindow *window,
>                                GdkEvent  *event)
> >  {
> >    GdkWindowPrivate *private;
> >    
> > @@ -701,8 +701,33 @@
> >      {
> >        if (private->window_type == GDK_WINDOW_FOREIGN)
> > 	gdk_window_internal_destroy (window, FALSE, FALSE);
> > -      else
> > +      else {
> > +	GdkWindowPrivate *parent;
> > +
> > 	g_warning ("GdkWindow %#lx unexpectedly destroyed", private->xwindow);
> hm since this will become a valid code path for bonobo then, wouldn't it make
> sense to actually take that warning out (it could be left as a debug option
> though) and actually invoke gdk_window_internal_destroy (window, FALSE, FALSE)
> here as well? especially since Gdk will then discard further operations on the
> window as well (we got checks all over the place for window_private->destroyed).
> owen?

This is not a valid code path. It means that the socket has
unexpectedly crashed. Nat's patch does not make that safe,
it just makes it work a lot more of the time. I think 
a warning is appropriate here.


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