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

Casting using as syntax is wrong(buggy) #120

Open
osa1 opened this issue Oct 22, 2014 · 1 comment
Open

Casting using as syntax is wrong(buggy) #120

osa1 opened this issue Oct 22, 2014 · 1 comment

Comments

@osa1
Copy link
Contributor

osa1 commented Oct 22, 2014

I just found a bug in my app caused by casting GLib/GTK pointer types using as. GTK has macros/functions like G_OBJECT, GTK_WIDGET, GTK_BOX etc. for casting and we need to use those. (also see the warning messages printed to console, those indicates errors in the wrappers)

I think we need to change traits to something like this:

(not tested)

pub trait FFIWidget<Ctype> {
    fn get_widget(&self) -> *mut Ctype;
    fn wrap(widget: *mut Ctype) -> Self;
}

We also need to remove as syntax used in macros like impl_TraitWidget! and use proper casting instead. Unfortunately this means adding whole lot of wrappers(like the ones in gtk_glue.c) from every widget type to GObject etc. I'm wondering if there's a better way to do this without using as at all.

@jeremyletang
Copy link
Owner

I don't think we should change the trait FFIWidget. But I agree with you, we should not use as style cast, but call ::gtk::ffi::cast_GtkObject().

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants