Re: Dialog hide/destroy
- From: muppet <scott asofyet org>
- To: "Juan José 'Peco' San Martín" <peco microbotica es>
- Cc: gtk-perl Mailing List <gtk-perl-list gnome org>
- Subject: Re: Dialog hide/destroy
- Date: Mon, 4 Jul 2005 11:22:32 -0400
On Jul 4, 2005, at 10:40 AM, Juan José 'Peco' San Martín wrote:
Now, I'm trying to do the same but using a main window with Menu
widget
that calls a new "dialog" window. All seems to be ok, but if I close
dialog window (delete_event) and try to re-open again (clicking on the
menu of the main one) I get:
Gtk-CRITICAL **: gtk_container_foreach: assertion `GTK_IS_CONTAINER
(container)' failed at ...
when I try to show the dialog again.
This typically means that you're trying to call ->show on a dead
widget. In your delete-event handler, what are you doing? If your
handler returns FALSE, the default handler will destroy the window;
to hide from delete event, you must set up your handler like this:
$window->signal_connect (delete_event => sub {
$_[0]->hide; # hide the window
return TRUE; # tell gtk+ that we handled this event, and
# that it should *not* destroy the window.
});
BTW, what it's the different between of using "hide"/"show" or
directly
"destroy" to control de windows behaviour?. It is always
recommended one
way to do it?. Is it faster vs memory-lesser?
gtk_widget_hide() unrealizes the widget, which takes it off of the
screen, but does not kill it. gtk_widget_destroy() hides and then
renders unusable the widget; the destroy is explicit in order to
break reference count cycles.
Whether you reuse or recreate widgets is entirely up to you and the
architecture of your application. If it takes a lot of work to
create a widget, or it should retain state between showings, then
it's likely a good idea to use hide instead of destroy. Destroying
the widget will obviously be the more memory-friendly approach.
There is no "best" way, in my experience; the answer is, "try both
and see which better satisfies your goals".
--
To me, "hajime" means "the man standing opposite you is about to hit
you with a stick".
-- Ian Malpass, speaking of the Japanese word for "the beginning"
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]