Re: Where to free dynamic allocated widgets, generated within signal handlers
Kjell Ahlstedt via gtkmm-list <[email protected]>
| Newsgroups | gmane.comp.gnome.gtkmm |
|---|---|
| Message-ID | <[email protected]> |
On 2020-01-04 12:14, Klaus wrote:
> Am 04.01.20 um 11:55 schrieb Kjell Ahlstedt:
>> I think
>> https://gitlab.gnome.org/GNOME/gtkmm-documentation/blob/gtkmm-3-24/examples/book/application/command_line_handling/exampleapplication.cc
>>
>> contains a solution to your problem. See
>> ExampleApplication::create_window() and
>> ExampleApplication::on_window_hide().
>>
> Thanks Kjell!
>
> What I see is, that the hide signal is delegated to some "other"
> instance which calls the delete.
>
>
> window->signal_hide().connect(sigc::bind<Gtk::Window*>(sigc::mem_fun(*this,
>
> &ExampleApplication::on_window_hide), window));
>
> void ExampleApplication::on_window_hide(Gtk::Window* window) {
> delete window; }
>
> My question still is: Is it safe to delete the "own" window the the
> "own" signal handler and which signal handler is best to use for the
> call to delete. Is it either on_hide() or on_delete_event(
> GdkEventAny* );
>
> Thanks!
> Klaus
I haven't tested, but I think you can override on_hide() and/or
on_delete_event() and "delete this;" there. Which one is called might
depend on how the window is hidden. on_hide() is called if the window is
hidden by pressing a button that calls hide(). I'm uncertain which
function is called if the window is closed by pressing the icon with a
cross, usually in the upper right-hand corner of the window.
Kjell
_______________________________________________
gtkmm-list mailing list
[email protected]
https://mail.gnome.org/mailman/listinfo/gtkmm-list