gtk-rs/gtk

Null pointer panic on `GestureZoom::connect_end`

piegamesde opened this issue · 4 comments

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

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? :)

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.