Re: concludeDragOperation, slide back, then crash
Re: concludeDragOperation, slide back, then crash
- Subject: Re: concludeDragOperation, slide back, then crash
- From: Greg Titus <email@hidden>
- Date: Fri, 28 Sep 2001 11:59:50 -0700
On Friday, September 28, 2001, at 02:30 PM, Gonzalo Castro wrote:
The problem I'm seeing is that after I drag a lot of files (more than
15, ~400k each) into my custom NSImageView, about half way through the
files being processed in setupForNewPictures(), the dragging image
slides back to the point of origin in the Finder and soon after my app
processes the last file path it crashes. Curiously, if I obtain the
_same_ list of files using OpenPanel and then pass these to
setupForNewPictures(), no problems. Also, dragging in fewer files works
as expected with no slide back. The slideback may not be related to the
crash but it is suspicious.
Thanks for any help.
There is a timeout in the system dragging facility (around 30 seconds?).
If your application doesn't conclude the drag within the timeout period,
the system assumes that you've gotten stuck, aborts the drag, and does
the slideback. When your app finally finishes, it returns from
-concludeDragOperation back into the system, which (I assume) then tries
to tell the system that the drag operation has completed, but there is
no such drag operation left, so there is a crash.
What you should do is implement your -concludeDragOperation so that it
simply queues the pictures to be processed later and then returns
immediately. An easy way to do that is to do a delayed perform (see the
docs for NSRunLoop) by writing something like:
[self performSelector:@selector(setupForNewPictures:)
withObject:picturesArray afterDelay:0];
(If the delay is zero the selector gets performed the next time your app
goes through the event loop.)
Hope this helps,
--Greg