Panic when calling `spawn_async` with callback
Description
When vte4::Terminal::spawn_async
is called with a callback passed in as the last parameter to the function, the function will cause a panic. This seems to be caused by the auto-generated code assuming that the error passed into the function is always a value, although it is actually a null pointer.
Example
use gio::Cancellable;
use glib::SpawnFlags;
use std::path::Path;
use vte4::{prelude::*, PtyFlags};
fn main() {
let application =
gtk::Application::new(Some("com.github.gtk-rs.examples.basic"), Default::default());
application.connect_activate(build_ui);
application.run();
}
fn build_ui(application: >k::Application) {
let window = gtk::ApplicationWindow::new(application);
window.set_title(Some("First GTK Program"));
window.set_default_size(350, 70);
let term = vte4::Terminal::new();
let envv_data = std::env::vars_os()
.map(|(mut a, b)| {
a.push("=");
a.push(b);
a
})
.collect::<Vec<_>>();
let envv = envv_data.iter().map(Path::new).collect::<Vec<_>>();
term.spawn_async(
PtyFlags::empty(),
None,
&[Path::new("nvim")],
&envv,
SpawnFlags::empty(),
Some(Box::new(|| {})),
-1,
Cancellable::NONE,
Some(Box::new(|t, p, e| {
dbg!(t, p, e);
})),
);
window.set_child(Some(&term));
window.show();
}
Backtrace
thread 'main' panicked at 'assertion failed: !ptr.is_null()', /home/lordmzte/.cargo/registry/src/github.com-1ecc6299db9ec823/glib-0.15.5/src/boxed.rs:435:9
stack backtrace:
0: rust_begin_unwind
at /rustc/e646f3d2a9541952310778288854943678738ea9/library/std/src/panicking.rs:584:5
1: core::panicking::panic_fmt
at /rustc/e646f3d2a9541952310778288854943678738ea9/library/core/src/panicking.rs:143:14
2: core::panicking::panic
at /rustc/e646f3d2a9541952310778288854943678738ea9/library/core/src/panicking.rs:48:5
3: <glib::boxed::Boxed<T,MM> as glib::translate::FromGlibPtrBorrow<*mut T>>::from_glib_borrow
at /home/lordmzte/.cargo/registry/src/github.com-1ecc6299db9ec823/glib-0.15.5/src/boxed.rs:435:9
4: glib::translate::from_glib_borrow
at /home/lordmzte/.cargo/registry/src/github.com-1ecc6299db9ec823/glib-0.15.5/src/translate.rs:1444:5
5: <glib::error::Error as glib::translate::FromGlibPtrBorrow<*mut glib_sys::GError>>::from_glib_borrow
at /home/lordmzte/.cargo/registry/src/github.com-1ecc6299db9ec823/glib-0.15.5/src/boxed.rs:192:32
6: glib::translate::from_glib_borrow
at /home/lordmzte/.cargo/registry/src/github.com-1ecc6299db9ec823/glib-0.15.5/src/translate.rs:1444:5
7: <O as vte4::auto::terminal::TerminalExt>::spawn_async::callback_func
at ./src/auto/terminal.rs:1346:25
8: _ZL14spawn_async_cbP8_GObjectP13_GAsyncResultPv
9: <unknown>
10: <unknown>
11: g_main_context_dispatch
12: <unknown>
13: g_main_context_iteration
14: g_application_run
15: <O as gio::application::ApplicationExtManual>::run_with_args
at /home/lordmzte/.cargo/registry/src/github.com-1ecc6299db9ec823/gio-0.15.5/src/application.rs:30:13
16: <O as gio::application::ApplicationExtManual>::run
at /home/lordmzte/.cargo/registry/src/github.com-1ecc6299db9ec823/gio-0.15.5/src/application.rs:23:9
17: main::main
at ./examples/main.rs:12:5
18: core::ops::function::FnOnce::call_once
at /rustc/e646f3d2a9541952310778288854943678738ea9/library/core/src/ops/function.rs:227:5
note: Some details are omitted, run with `RUST_BACKTRACE=full` for a verbose backtrace.
fatal runtime error: Rust panics must be rethrown
The error occurs in src/auto/terminal.rs
, line 1346, where from_glib_borrow
is called with a null pointer.