-
-
Notifications
You must be signed in to change notification settings - Fork 82
GtkWindow "set-focus" Signal Parameter is Nullable #985
Comments
Here's a backtrace with better symbols. The null focus comes from
|
And a minimal case: extern crate gio;
extern crate gtk;
use gio::prelude::*;
use gtk::prelude::*;
use std::env::args;
fn build_ui(application: >k::Application) {
let window = gtk::ApplicationWindow::new(application);
window.set_title("null poc");
window.set_border_width(10);
window.set_position(gtk::WindowPosition::Center);
window.set_default_size(350, 70);
let button = gtk::Button::new_with_label("Click me!");
window.add(&button);
window.show_all();
button.grab_focus();
window.connect_set_focus(|_, _| println!("got set focus signal"));
button.hide();
}
fn main() {
let application =
gtk::Application::new(None, Default::default())
.expect("Initialization failed.");
application.connect_activate(|app| {
build_ui(app);
});
application.run(&args().collect::<Vec<_>>());
} |
Seems to be an upstream issue caused by someone having botched the formatting on the signal's annotation GNOME/gtk@93bcca7. There is one colon where in every other annotation there are two. |
Ugh, but this signal seems to have actually recently been entirely removed from mainline GTK in favor of the |
And the story continues to develop, since the |
git master of GTK is GTK 4, GTK 3 is maintained in a branch. These bindings are for GTK 3. So two steps are needed here: 1) report this to GTK against their GTK 3 branch, ideally as a MR, 2) fix it on our side by adding the |
Probably also want to do a short check with grep if there are other such documentation/annotation mistakes in GTK. |
Fixed upstream: https://gitlab.gnome.org/GNOME/gtk/-/merge_requests/1677. |
Perhaps this issue should be left open so that we don't forget to remove the workaround when the upstream fix makes its way into gir-files. |
It is poorly (read: not) documented, but the "set-focus" on GtkWindow signal's
widget
parameter can be null.https://developer.gnome.org/gtk3/stable/GtkWindow.html
I know this because I had it happen to me. See
(ptr=0x0)
in the backtrace.The signature of gtk::GtkWindowExt::connect_set_focus's callback probably needs to be changed to take a
Option<&Widget>
. Or, (and I expect this to be the more preferable option), the code generator needs to somehow be informed that this value is nullable. Not sure how to do that myself or I'd PR it.The text was updated successfully, but these errors were encountered: