Surya Kiran Gullapalli wrote:
Hi,
I'm writing a small application, which should display a window with an
image in it, with out window borders (similar to splash window).
I'm trying to add image to the window using add () function
here pix is const Glib::RefPtr<Gdk::Pixbuf>&
=============
Gtk::Image *image = new Gtk::Image (pix) ;
add (*image) ;
image->show() ;
=============
This works fine. But the memory allocated to image is lost. I've to
retrieve it.
So i've done like this
=============
Gtk::Image image (pix) ;
add (image) ;
image.show() ;
=============
But when i do this, the image is not visible. (Reason could be , after
the function, image will be out of scope and will be destroyed, as its
not a pointer
The same thing happens, if i use auto_ptr also
=============
std::auto_ptr<Gtk::Image> image (new Gtk::Image (pix))
add (*image) ;
image->show() ;
=============
what am i doing wrong. Its very much possible, that i'm doing a very
silly mistake, or i must have not understood the basics of c/c++ well.
If i use pointer, how to free the memory allocated to it.
Thx,
Surya
_______________________________________________
gtkmm-list mailing list
gtkmm-list gnome org
http://mail.gnome.org/mailman/listinfo/gtkmm-list
Hey Surya,
If you write your initial code this way:
Gtk::Image *image =
manage(new Gtk::Image (pix));
add (*image) ;
image->show() ;
Then the memory allocation for your image will be handled by the
container into which you insert it and you won't have to worry about
deleting the storage.
--
Robert
L Caryl Jr
Fiscal
Systems, Inc.
256-772-8920 Ext. 108
This
email message may contain privileged or confidential information. If
you are not the recipient, you may not disclose, use, disseminate,
distribute, copy or rely on this message or attachment in any way. If
you received this email message in error, please return by forwarding
the message and its attachment to the sender and then delete the
message and its attachment from your computer. Fiscal Systems, Inc.
and its affiliates do not accept liability for any errors, omissions,
corruption or virus in the contents of this message or any
attachments that arise as a result of e-mail transmission.
|