Re: [gtkmm] Pixbuf memory management

Am Mon, 2002-10-28 um 21.00 schrieb Murray Cumming:
> On Mon, 2002-10-28 at 20:52, Jussi Pakkanen wrote:
> > The problem is this: when and who should free the
> > temporary array of RGB values I constructed? The
> > documentation seems to implicate that creating the
> > pixbuf does not make a copy of the data. This seems a
> > little counterintuitive. I just want to create a
> > pixbuf from my temporary data and then delete it
> > without affecting the pixbuf.
> Yes, it looks like you need to keep the data around for as long as the
> pixbuf. The documentation for the underlying structure does seem to
> suggest that we could change it, by taking a copy (maybe inefficiently)
> and supplying a callback to delete it:
> But I think it's too late for that. If you submit a patch then we can
> consider it for the next API break.

Erm, I don't see the problem here.  The 2nd overload of
Gdk::Pixbuf::create_from_data() takes a SigC::Slot to a custom destroy
function, so you can simply do:

void destroy_image_data(const guint8* data)
  delete data;

and pass this function for the destroy_slot argument.


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]