Bug in Tk_HandleEvent stops tkdnd from working under unix...

From: George Petasis (petasis_at_iit.demokritos.gr)
Date: 02/28/05


Date: Mon, 28 Feb 2005 22:12:48 +0200

Dear all,

I think I have found the cause that tkdnd has stopped working
with recent versions of tk for more than a year :-)

In file, generic/tkEvent.c, the code in Tk_HandleEvent
has changed (I don't know when), so as ClientMessage
handlers (registered with Tk_CreateClientMessageHandler)
are now processed through a new function,
InvokeClientMessageHandlers. However, the code in
InvokeClientMessageHandlers is:

GenericHandler *curPtr = tsdPtr->cmList;
for (prevPtr = NULL; curPtr != NULL; ) {
         if (curPtr->deleteFlag) {
            if (!tsdPtr->handlersActive) {
                /*
                 * This handler needs to be deleted and there are
                 * no calls pending through any handlers, so now
                 * is a safe time to delete it.
                 */
                // -- Handler gets deleted --
            } else {
                int done;

                tsdPtr->handlersActive++;
                done = (*(Tk_ClientMessageProc *)curPtr->proc)
                  (tkwin, eventPtr);
                tsdPtr->handlersActive--;
                if (done) {
                    break;
                }
            }
         }
        prevPtr = curPtr;
        curPtr = curPtr->nextPtr;
     }
}

curPtr->deleteFlag is true only after a call to
Tk_DeleteClientMessageHandler, and this function does nothing
when curPtr->deleteFlag is false. Thus, all registered ClientMessage
handlers are not executed. Should this function be fixed to
be equivelant to InvokeGenericHandlers?

George