Michael Sweet wrote:

> I'd actually vote to move the refcounting to Fl_Image, and then
> Fl_Shared_Image's destructor can remove the image from the shared
> image list.

That's something I thought about, too, but I can't see how this
would work. I have problems with the protected virtual destructor
of Fl_Shared_Image, anyway. Refcounting is based on the fact
that you can't destroy a Fl_Shared_Image by using delete, you
must call release(). Okay so far. You can't create a static or
local object, so this is okay (no automatic destructors).

But what, if I use:

  Fl_Image *img = shared_img->copy(100,100);
  ...
  delete img;

What happens? Note that img points to an Fl_Shared_Image object.
The compiler can't detect this, can it? Will the Fl_Shared_Image
be destroyed?

Will ~Fl_Shared_Image() be called, and what should this do?
Currently the Fl_Shared_Image would be removed from the image
list only if release() would be called, but we'd have a problem
anyway, since there might be other pointers to the shared image.

Am I wrong here, or how can we solve this? A simple "don't do
that"?

Albrecht
_______________________________________________
fltk-dev mailing list
[email protected]
http://lists.easysw.com/mailman/listinfo/fltk-dev

Reply via email to