Problem: 1615430

Title: (Drag & Drop -Into trash) TDragItemList isn't initialized properly

Received: Dec 24 1996 11:16AM


D&D from my view to the finder trash does not initializes the TDragItemList In my view one can select multiple items to drag away, each is added to the D&D with
TDragItem *dragItem =
TDragDropSession::fgDragDropSession->AddDragItem(some unique number);
TDragDropSession:: HandleDragToTrash calls
        CDragItemIterator   dragItemIterator(fDragItemList);
        DoMakeDragDropCommand(cDrag, dragItemIterator)
but fDragItemList isn't set up properly....

this is what I had to do to make it work....

TCommand* TJobValueSetListView::DoMakeDragDropCommand( CommandNumber
                   itsCommandNumber, CDragItemIterator& dragItemIterator)
{
    TCommand *returnCommand = NULL;
    switch (itsCommandNumber)
    {
         case cDrag:
            {
                if (!TDragDropSession::fgDragDropSession->UserRequestedCopy()
                            && TDragDropSession::fgDragDropSession->IsDropLocationFinderTrash())
                {
                    MAVolatileInit(TDragItemList *,dragItemList, NULL);
                    MAVolatileInit(TJobListDeleteCommand *,deleteCmd, NULL);
                    FailInfo fi;
                    Try(fi)
                    {
                        // build own dragItemList
                        // HandleDragToTrash has a bug of having an empty list all the time...
                        TDragItemList *aDragItemList = new TDragItemList;
                        aDragItemList->IDragItemList();
                        dragItemList = aDragItemList;
                        dragItemList->BuildListFromDrag();
                        TJobListDeleteCommand *aDeleteCmd  = new TJobListDeleteCommand ;
                        aDeleteCmd ->IJobListDeleteCommand (itsCommandNumber, this, kCantUndo, kDoesNotCauseChange, this, false);
                        deleteCmd = aDeleteCmd;
                        CDragItemIterator aDragItemIterator(dragItemList);
                        TDragItem *dragItem = NULL;
                        for (dragItem = aDragItemIterator.FirstDragItem(); aDragItemIterator.More(); dragItem = aDragItemIterator.NextDragItem())
                            deleteCmd->AddJobDescription(dragItem->GetItemReference());
                        dragItemList->FreeAll();
                        dragItemList = (TDragItemList*)FreeIfObject(dragItemList);
                        returnCommand = deleteCmd;
                    }
                    else // Recover
                    {
                        if (dragItemList)
                        {
                            dragItemList->FreeAll();
                            dragItemList = (TDragItemList*)FreeIfObject(dragItemList);
                        }
                        if (deleteCmd)
                            deleteCmd = (TJobListDeleteCommand*)FreeIfObject(deleteCmd);
                    }
                }
            }
            break;

>A while ago (Dec. 19th) you sent in a bug report entitled "MacApp 3.3.1
>bugs" which describes a problem you were having dragging things to the
>trash.  Specifically, you mentioned the work-around you had to implement in
>your TJobValueSetListView::DoMakeDragDropCommand.
>
>You said the following in that message:
>
>>D&D from my view to the finder trash does not initializes the TDragItemList
>>In my view one can select multiple items to drag away, each is added to
>>the D&D with
>>
>>TDragItem * dragItem =
>>TDragDropSession::fgDragDropSession->AddDragItem(some unique number);
>>
>>TDragDropSession:: HandleDragToTrash calls
>>
>>	CDragItemIterator   dragItemIterator(fDragItemList);
>>	DoMakeDragDropCommand(cDrag, dragItemIterator);
>>
>>but fDragItemList isn't set up properly...
>
>I've taken a look at this and at the rest of your message but I'm not too
>sure what you meant when you said, "but fDragItemList isn't set up
>properly.."  I've looked throughout the code and fDragItemList is
>initialized as expected in InitUDragManager.  It should be inserting
>elements as you call AddDragItem.
>
>Would you mind providing a bit more clarification on this?

As far as I remember In my case fDragItemList was always empty because 
when dragging to the trash you leave the window and when brousing the 
code I noticed the drag handling code clears the fDragItemList when 
leaving the window. In my case Server/Client app I act on the 
DoMakeDragDropCommand to send off cmd's to the server to delete the 
items...