DnD code does not check whether a toolkit image is ready to be painted
into a buffer. We have to do this check in order to get correct image
Suggested fix just delegates the conversion of toolkit image into a
CImage instance to a helper class CImage.Creator. This helper class
provides two ways to convert a toolkit image int CImage:
- immediate conversion: returns valid CImage only if toolkit image
has valid dimension, and null otherwise.
Immediate conversion works fine for toolkit images which are
prepared in advance, or are based on memory image source.
- normal conversion: a toolkit image is prepared for rendering using
a media tracker.
We can not use the normal conversion in case of DnD, because broken
toolkit image (whose producer never updates the image state for any
reasons) can cause a hang in the DnD the code (test in question
implements such scenario).
If supplied drag image can not be conversed to CImage (either an
exception is thrown or it is not ready, i.e. a result of conversion
is null for any reasons) the InvalidDnDOperationException is thrown
in order to notify user about the problem with drag image.
Note that such approach is already used on windows platform, so with
this fix, macosx behaves in a uniform way with windows.
Beside this, this fix pushes the drag image (an instance of CImage)
down to native DnD machinery in order to be able to display drag