Closed gdesmott closed 1 month ago
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>,
I tried with this, and it seems to work:
#[property(get, set, type = SimpleEnum, member = senum, builder(SimpleEnum::default()))]
inner_enum: Mutex<Inner>,
@gdesmott could you add a full reproducer of the issue please?
@gdesmott could you add a full reproducer of the issue please?
There is in this commit: https://github.com/gdesmott/gtk-rs-core/commit/f7d6a6049b44c298c56cbc1e4b6fb9ff218f46a9
Indeed something going wrong with the traits there. Annoying that rust-analyzer doesn't seem to be able to expand the derive macro, that would simplify debugging.
There's actually no bug here, sorry.
--- a/glib-macros/tests/properties.rs
+++ b/glib-macros/tests/properties.rs
@@ -163,7 +163,7 @@ mod foo {
construct_only_cell: OnceCell<u32>,
#[property(get, set = Self::set_construct_only_custom, construct_only)]
construct_only_custom_setter: OnceCell<Option<String>>,
- #[property(get, set, member = senum)]
+ #[property(get, set, member = senum, type = SimpleEnum, builder(SimpleEnum::One))]
inner_enum: Mutex<StructWithEnum>,
}
When going via member = ...
, you always need to specify the property type. And for enum properties you need to provide the builder.
See this code trying to define a GEnum property inside a nested object. It fails, I think, because
type =
needs to be defined when usingmember =
but I didn't find any way to make it work.