Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix panic in generating `emit` for incomplete signal #621

Merged
merged 1 commit into from Jul 4, 2018

Conversation

Projects
None yet
2 participants
@EPashkin
Copy link
Member

EPashkin commented Jul 4, 2018

Fix panic on GObject generation (see #620 (comment)).

cc @sdroege

@EPashkin

This comment has been minimized.

Copy link
Member Author

EPashkin commented Jul 4, 2018

Also can be fixed by just adding "GObject.ParamSpec" to manual in Gir_GObject.toml,
but with this we can find which type need be deignored

@@ -75,6 +75,11 @@ pub fn generate(
}
}

if function_type.is_none() {
// Signal incomplete, can't generate emit
return Ok(());

This comment has been minimized.

@sdroege

sdroege Jul 4, 2018

Member

Makes sense, but which signal is that exactly?

This comment has been minimized.

@EPashkin

EPashkin Jul 4, 2018

Author Member

Notify

    fn connect_notify<F: Fn(&Self, &ParamSpec) + 'static>(&self, f: F) -> SignalHandlerId {
        unsafe {
            let f: Box_<Box_<Fn(&Self, &ParamSpec) + 'static>> = Box_::new(Box_::new(f));
            connect(self.to_glib_none().0, "notify",
                transmute(notify_trampoline::<Self> as usize), Box_::into_raw(f) as *mut _)
        }
    }

    fn emit_notify(&self, pspec: &ParamSpec) {
        let _ = self.emit("notify", &[&pspec]).unwrap();
    }

unsafe extern "C" fn notify_trampoline<P>(this: *mut gobject_ffi::GObject, pspec: *mut gobject_ffi::GParamSpec, f: glib_ffi::gpointer)
where P: IsA<Object> {
    let f: &&(Fn(&P, &ParamSpec) + 'static) = transmute(f);
    f(&Object::from_glib_borrow(this).downcast_unchecked(), &from_glib_borrow(pspec))
}

This comment has been minimized.

@sdroege

sdroege Jul 4, 2018

Member

What is the problem here? But we shouldn't generate this notify function for other reasons :)

This comment has been minimized.

@EPashkin

EPashkin Jul 4, 2018

Author Member

Without manual ParamSpec it looks after fix with unspecified closure type (function_type variable)

    //fn connect_notify<Unsupported or ignored types>(&self, f: F) -> SignalHandlerId {
    //    Ignored pspec: GObject.ParamSpec
    //}

This comment has been minimized.

@sdroege

sdroege Jul 4, 2018

Member

I see, makes sense

@EPashkin

This comment has been minimized.

Copy link
Member Author

EPashkin commented Jul 4, 2018

Ok, let merge this then

@EPashkin EPashkin merged commit 4c7ff69 into gtk-rs:master Jul 4, 2018

2 checks passed

continuous-integration/appveyor/pr AppVeyor build succeeded
Details
continuous-integration/travis-ci/pr The Travis CI build passed
Details

@EPashkin EPashkin deleted the EPashkin:fix_panic_in_emit_generation branch Jul 4, 2018

vhdirk pushed a commit to vhdirk/gir that referenced this pull request Jul 6, 2018

Merge pull request gtk-rs#621 from EPashkin/fix_panic_in_emit_generation
Fix panic in generating `emit` for incomplete signal
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.