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

[BUG] not able to use the Property macro with a nested GEnum #1338

Open
gdesmott opened this issue Mar 20, 2024 · 4 comments
Open

[BUG] not able to use the Property macro with a nested GEnum #1338

gdesmott opened this issue Mar 20, 2024 · 4 comments
Labels
bug Something isn't working glib glib-macros

Comments

@gdesmott
Copy link
Contributor

See this code trying to define a GEnum property inside a nested object. It fails, I think, because type = needs to be defined when using member = but I didn't find any way to make it work.

error[E0277]: the trait bound `std::sync::Mutex<foo::Inner>: Property` is not satisfied
   --> glib-macros/tests/properties.rs:159:13
    |
159 |             #[property(get, set, member = senum)]
    |             ^ the trait `Property` is not implemented for `std::sync::Mutex<foo::Inner>`
    |
    = help: the trait `Property` is implemented for `std::sync::Mutex<T>`

error[E0277]: the trait bound `std::sync::Mutex<foo::Inner>: Property` is not satisfied
  --> glib-macros/tests/properties.rs:90:18
   |
90 |         #[derive(Properties, Default)]
   |                  ^^^^^^^^^^ the trait `Property` is not implemented for `std::sync::Mutex<foo::Inner>`
   |
   = help: the trait `Property` is implemented for `std::sync::Mutex<T>`
   = note: this error originates in the derive macro `Properties` (in Nightly builds, run with -Z macro-backtrace for more info)

@gdesmott gdesmott added the bug Something isn't working label Mar 20, 2024
@gdesmott
Copy link
Contributor Author

It seems to work when using a custom get implementation:

#[property(get = |t: &Self| t.inner_enum.lock().unwrap().senum.to_owned(), type = SimpleEnum, builder(SimpleEnum::One))]
inner_enum: Mutex<Inner>,

@zecakeh
Copy link
Contributor

zecakeh commented Apr 12, 2024

I tried with this, and it seems to work:

#[property(get, set, type = SimpleEnum, member = senum, builder(SimpleEnum::default()))]
inner_enum: Mutex<Inner>,

@bilelmoussaoui
Copy link
Member

@gdesmott could you add a full reproducer of the issue please?

@gdesmott
Copy link
Contributor Author

@gdesmott could you add a full reproducer of the issue please?

There is in this commit: gdesmott@f7d6a60

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working glib glib-macros
Projects
None yet
Development

No branches or pull requests

3 participants