Missing `unrealize` with `make_window_and_run`.
An important invariant of the lifecycle of any widget is that realization is followed by unrealization. Without this guarantee, there is little hope of building reliable software.
When porting an application from GTKmm 3 to 4, and making use of the new make_window_and_run
as recommended by examples, I found this invariant to be broken. Here is an MWE:
#include <gtkmm/application.h>
#include <gtkmm/window.h>
#include <iostream>
struct Window : Gtk::Window
{
Window() {std::cout << "ctor\n";}
void on_realize() override
{
std::cout << "realize\n";
Gtk::Window::on_realize();
}
void on_unrealize() override
{
std::cout << "unrealize\n";
Gtk::Window::on_unrealize();
}
~Window() override {std::cout << "dtor\n";}
};
int main(int argc, char* argv[])
{
auto app = Gtk::Application::create();
return app->make_window_and_run<Window>(argc, argv);
}
This prints
ctor
realize
dtor
It should print
ctor
realize
unrealize
dtor