Problem: 1625672

Title: (Script -TCommandHandler) Pending action problem with window

Received: Feb 4 1997 10:21AM


there is a bug having to do with factored applications and command objects whose context is a window.

in TCommandHandler::PerformCommandAppleEvent sets fPendingActionID, it sets it in the current command handler for the command, in this case the window.

when TOSADispatcher::DispatchHandler gets an apple event and calls IsPendingAction to see if this is a factored command. MScriptableObject::IsPendingAction checks fPendingActionID of the command handler returned by GetCommandContext( aCommandNumber). the problem arrises because TWindow overrides GetCommandContext to return either its fDocument or gDispatcher, and thus this is not seen as a pending action. the result of this not being a pending action is that the command is then passed on to DoScriptCommand and we wind up with 2 copies of the command and lots of problems ensue.

i've implemented the following fix:

in TCommandHandler::PerformCommandAppleEvent

change:

   fPendingActionID = transactionID;
to:
   MScriptableObject* scriptableObject =
          MA_DYNAMIC_CAST(MScriptableObject, this);
   if (scriptableObject) {
      TCommandHandler* commandHandler =
          scriptableObject->GetCommandContext( command->fIdentifier);
      if (commandHandler)
         commandHandler->fPendingActionID = transactionID;
      else
         fPendingActionID = transactionID;
      }
   else
      fPendingActionID = transactionID;
and add:
#ifndef __USCRIPTABLEOBJECT__
#include "UScriptableObject.h"
#endif
at the front of UCommandHandler.cp