Fabien Costantini wrote:
>> Fabien Costantini wrote:
> 
>> But then you want to destroy the object, and then you must
>> know, which type of object it really is: if it's an
>> Fl_Shared_Image you must cast it to (Fl_Shared_Image *) and
>> then call "image->release()" or do something equivalent, but
>> if it is not, then you must call "delete image". I know that
>> there are different ways to achieve this (including dynamic_cast),
>> but simply calling "delete image" without distinction would
>> do the _wrong_ thing if it is really an Fl_Shared_Image.
>>
>> And no compiler would warn you about it, although
>> ~Fl_Shared_Image() is protected. That's the point!
> This is exactly why mike suggested to implement release() in the Fl_Image 
> class I think.
> This way, we could avoid completely the need of deleting images.
> a release base impl. would just delete himself in the non shared image impl.,
> the shared image would do what it does now.

I think we'd just move the reference counting and automatic deletion
when the count == 0 to Fl_Image.  Then you could use either method
(although for the base image classes it is far more likely you'll
just delete, implicitly or explicitly, rather than do the retain/
release dance...)

-- 
______________________________________________________________________
Michael Sweet, Easy Software Products           mike at easysw dot com
_______________________________________________
fltk-dev mailing list
[email protected]
http://lists.easysw.com/mailman/listinfo/fltk-dev

Reply via email to