Re: preferred way to destroy a window

On Thu, 2006-08-03 at 22:01 +0300, Paul Pogonyshev wrote:
> Hi,
> Maybe it is a stupid question, but I was unable to find the answer.
> What is the preferred way to destroy a window in Gtkmm?

delete, as for other C++ objects.

For instance,

Gtk::Window* window = new Gtk::Window();
delete window;

If what you actually want to do is hide the window then just call hide:

>   In pure C
> I'd call gtk_widget_destroy(), but what do I do in C++?  (Calling
> `delete this' leads to a segmenation fault, but maybe it's my error,
> not sure...)

"delete this" should also work, as for other C++ objects, though many
people prefer to avoid it, because you need to be very careful that the
window is not being used elsewhere.

Also, "delete this" would obviously cause a segfault if the window was
not allocated with new - for instance if the instance was a member
variable of another class, as in many of the gtkmm examples.

If this doesn't explain things, try posting a small example of what you
are doing.
Murray Cumming
murrayc murrayc com

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