Re: The recommended way to destroy a Gtk::Dialog on response?



You can also put the object into a smart pointer. I'd recommend
boost's shared_ptr.

Paul

On 6/6/07, Murray Cumming <murrayc murrayc com> wrote:
On Wed, 2007-06-06 at 10:16 +0200, Toralf Lund wrote:
> Just found myself in a situation where a Gtk::Dialog has to be
>
>    1. Allocated using "new"
>    2. Deleted as and when the user presses a button, i.e. on "response".
>
> (I'm otherwise using Gtk::Dialog with local variables and the run()
> method most of the time.)
>
> So, what's the best way of setting up for deletion of the object? I
> mean, I know how it may be done, of course, but is there any kind of
> built-in support, or any recommendations?

Just delete it, like any other object.

>  Seems to me that the obvious
> solution, i.e. doing "delete this" inside a signal handler, is something
> that one would not necessarily recommend...

Yes, I would personally avoid doing "delete this", and I would avoid
deleting things in the signal handler for the object that I'm deleting.

But this is actually meant to work, so it would be a bug if it didn't.
glib and GTK+ and libsigc++ and gtkmm has code to support it.

--
Murray Cumming
murrayc murrayc com
www.murrayc.com
www.openismus.com

_______________________________________________
gtkmm-list mailing list
gtkmm-list gnome org
http://mail.gnome.org/mailman/listinfo/gtkmm-list




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