# HG changeset patch # User aidan # Date 1109788317 0 # Node ID 140bb0f4da004306bc862ec4b5a188f25edacd9e # Parent 63a49b9b070cf436959ca5cfa88f16b8d68d9f7e [xemacs-hg @ 2005-03-02 18:31:55 by aidan] Wrap call to XtRegisterDrawable with check that XtWindowToWidget gives NULL, document why. diff -r 63a49b9b070c -r 140bb0f4da00 src/ChangeLog --- a/src/ChangeLog Wed Mar 02 17:55:25 2005 +0000 +++ b/src/ChangeLog Wed Mar 02 18:31:57 2005 +0000 @@ -1,3 +1,9 @@ +2005-03-02 Aidan Kehoe + + * select-x.c (x_reply_selection_request): Check that + XtWindowToWidget returns NULL before calling XtRegisterDrawable, + document why. + 2005-03-02 Aidan Kehoe * select-x.c (x_reply_selection_request): Make the error message diff -r 63a49b9b070c -r 140bb0f4da00 src/select-x.c --- a/src/select-x.c Wed Mar 02 17:55:25 2005 +0000 +++ b/src/select-x.c Wed Mar 02 18:31:57 2005 +0000 @@ -545,8 +545,24 @@ target window, rather, pass them to us. This would be a hack, but the Xt selection routines are broken for our purposes--we can't pass them callbacks from Lisp, for example. Let's call it a - workaround. */ - XtRegisterDrawable(display, (Drawable)window, widget); + workaround. + + The call to wait_for_property_change means we can break out of that + function, switch to another frame on the same display (which will + be another Xt widget), select a huge amount of text, and have the + same (foreign) app ask for another incremental selection + transfer. Programming like X11 made sense, would mean that, in that + case, XtRegisterDrawable is called twice with different widgets. + + Since the results of calling XtRegisterDrawable when the drawable + is already registered with another widget are undefined, we want to + avoid that--so, only call it when XtWindowToWidget returns NULL, + which it will only do with a valid Window if it's not already + registered. */ + if (NULL == XtWindowToWidget(display, window)) + { + XtRegisterDrawable(display, (Drawable)window, widget); + } prop_id = expect_property_change (display, window, reply.property, PropertyDelete);