Re: Dialog hide/destroy




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.
   });


You're completly right. Thanks!

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.

Ok

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".

Ok!

Thanks again.
Peco


--
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]