Closed andy128k closed 2 years ago
How this worked before ? Pretty sure it didn't. We need a way to register a hook into gio::ApplicationImpl to mark gtk as intialiazed before the startup vfunc is run and the code doesn't do that, there is an open issue on gtk4-rs for the same thing .
@A6GibKm it definitely IS a regression. Gtk promises that GtkApplication does initialization.
It’s important to note that if you use GtkApplication, the application class will take care of initializing GTK for you, as well as spinning the main loop.
Bug is caused by a state rt::INITIALIZED
in gtk-rs be out of sync with Gtk's state.
Please look at the issue I attached it explains why it never worked before.
@bilelmoussaoui The issue you've linked explains why rt::INITIALIZED
was not reliable (and still is). It does not contradict to my statement that 0.15.x is broken.
I cannot say for gtk3 as i havent used it in some time. But I assure you it never worked in gtk4-rs.
@A6GibKm It works(-ed) in gtk4-rs. I have a gtk4 branch of the same app (but cannot merge in because of https://github.com/gtk-rs/gtk4-rs/issues/584).
The workaround would be to call gtk::set_initialized
at the right place in your code.
For solving this properly, maybe we should just initialize gtk ourselves before calling startup()
. @bilelmoussaoui what do you think?
@sdroege We already do https://github.com/gtk-rs/gtk3-rs/blob/master/gtk/src/subclass/application.rs#L92? or do you suggest calling 'gtk::init' there?
Yes, calling gtk::init()
before calling imp.startup()
. That's ugly but at least solves it once and for all.
@sdroege or maybe we could use something similar to what we did for gtk_widget_class_install_action
and store a function to be called before gio::ApplicationImp::startup ? it shouldn't be hard to do, i can give it a look this weekend
It has to happen after GtkApplication::startup
ran, but I have an idea.
If someone has a testcase for me then I can make this work probably.
This is fixed in 0.15.2 now
A program, which subclasses
gtk::Application
and does not invokegtk::init
explicitly, panics withBacktrace