Window destructor not called

Hello,

why in this example the window destructor is not called, I’m using Vala 0.56.3 and GTK 4.8.2.

public class CustomWindow : Gtk.ApplicationWindow {
	public CustomWindow (Gtk.Application app) {
		Object (application: app);
	}

	~CustomWindow () {
		print ("~CustomWindow\n");
	}
}

public static int main (string[] argv) {
	var app = new Gtk.Application ("com.example.App", ApplicationFlags.FLAGS_NONE);
	app.activate.connect (() => {
		var window = new CustomWindow (app);
		var button = new Gtk.Button.with_label ("Close!");
		button.clicked.connect (() => window.close ());
		window.child = button;
		window.present ();
	});
	return app.run (argv);
}

Compiled with:

valac --pkg gtk4 example.vala

A similar example using GTK3 works as expected.

How do you close the window? If you just type ^C in the terminal, the objects don’t get released properly, so the destructor is not called.

hm. the window.close () method, doent destroy the window I think. It is still there.

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.