gtk-rs / gtk

DEPRECATED, use https://github.com/gtk-rs/gtk3-rs repository instead!
https://gtk-rs.org/
MIT License
1.25k stars 82 forks source link

Null pointer panic on `GestureZoom::connect_end` #1050

Closed piegamesde closed 4 years ago

piegamesde commented 4 years ago

I built a simple pinch-to-zoom for my widget and most of the time, the application panics at the end of the zoom gesture. Stack trace:

thread 'main' panicked at 'assertion failed: !ptr.is_null()', /build/rustc-1.45.0-src/src/libstd/macros.rs:13:23
stack backtrace:
   0: <std::sys_common::backtrace::_print::DisplayBacktrace as core::fmt::Display>::fmt
   1: core::fmt::write
   2: std::io::Write::write_fmt
   3: std::panicking::default_hook::{{closure}}
   4: std::panicking::default_hook
   5: std::panicking::rust_panic_with_hook
   6: std::panicking::begin_panic
             at /build/rustc-1.45.0-src/src/libstd/panicking.rs:410
   7: <glib::boxed::Boxed<T,MM> as glib::translate::FromGlibPtrBorrow<*mut T>>::from_glib_borrow
             at /build/rustc-1.45.0-src/src/libstd/macros.rs:13
   8: glib::translate::from_glib_borrow
             at src/github.com-1ecc6299db9ec823/glib-0.10.1/src/translate.rs:1321
   9: <gdk::auto::event_sequence::EventSequence as glib::translate::FromGlibPtrBorrow<*mut gdk_sys::GdkEventSequence>>::from_glib_borrow
             at src/github.com-1ecc6299db9ec823/glib-0.10.1/src/boxed.rs:188
  10: glib::translate::from_glib_borrow
             at src/github.com-1ecc6299db9ec823/glib-0.10.1/src/translate.rs:1321
  11: <O as gtk::auto::gesture::GestureExt>::connect_end::end_trampoline
             at src/github.com-1ecc6299db9ec823/gtk-0.9.1/src/auto/gesture.rs:363
  12: g_cclosure_marshal_VOID__BOXEDv
  13: _g_closure_invoke_va
  14: g_signal_emit_valist
  15: g_signal_emit
  16: _gtk_gesture_check_recognized
  17: gtk_gesture_handle_event
sdroege commented 4 years ago

The signal handlers for GtkGesture should all take an Option<&gdk::Sequence> (can be configured to be nullable in the Gir.toml), and nullable annotations should also be added to the GTK docs.

Want to provide a PR for either of these two? :)

piegamesde commented 4 years ago

No, sorry. I have no experience with C bindings, Gir or the gtk-rs source code, so getting started with all of this could take quite some time.

sdroege commented 4 years ago

Ok, https://gitlab.gnome.org/GNOME/gtk/-/merge_requests/2520 for the part in GTK for now.

sdroege commented 4 years ago

See https://github.com/gtk-rs/gtk/pull/1053