mirror of
https://github.com/slint-ui/slint.git
synced 2025-08-04 18:58:36 +00:00
Emit a warning to stderr (debug_log) when using the ElementHandle API but there's no debug info present
This commit is contained in:
parent
622991a627
commit
15b517a554
5 changed files with 80 additions and 40 deletions
|
@ -1410,10 +1410,10 @@ fn generate_item_tree(
|
|||
Declaration::Function(Function {
|
||||
name: "element_infos".into(),
|
||||
signature:
|
||||
"([[maybe_unused]] slint::private_api::ItemTreeRef component, uint32_t index, slint::SharedString *result) -> void"
|
||||
"([[maybe_unused]] slint::private_api::ItemTreeRef component, uint32_t index, slint::SharedString *result) -> bool"
|
||||
.into(),
|
||||
is_static: true,
|
||||
statements: Some(vec![format!("*result = reinterpret_cast<const {}*>(component.instance)->element_infos(index);", item_tree_class_name)]),
|
||||
statements: Some(vec![format!("if (auto infos = reinterpret_cast<const {}*>(component.instance)->element_infos(index)) {{ *result = *infos; return true; }};", item_tree_class_name), "return false;".into()]),
|
||||
..Default::default()
|
||||
}),
|
||||
));
|
||||
|
@ -2044,7 +2044,7 @@ fn generate_sub_component(
|
|||
|
||||
dispatch_item_function(
|
||||
"element_infos",
|
||||
"(uint32_t index) const -> slint::SharedString",
|
||||
"(uint32_t index) const -> std::optional<slint::SharedString>",
|
||||
"",
|
||||
element_infos_cases,
|
||||
);
|
||||
|
|
|
@ -837,7 +837,7 @@ fn generate_sub_component(
|
|||
let mut item_element_infos_branch = component
|
||||
.element_infos
|
||||
.iter()
|
||||
.map(|(item_index, ids)| quote!(#item_index => { return #ids.into(); }))
|
||||
.map(|(item_index, ids)| quote!(#item_index => { return sp::Some(#ids.into()); }))
|
||||
.collect::<Vec<_>>();
|
||||
|
||||
let mut user_init_code: Vec<TokenStream> = Vec::new();
|
||||
|
@ -1158,7 +1158,7 @@ fn generate_sub_component(
|
|||
}
|
||||
}
|
||||
|
||||
fn item_element_infos(self: ::core::pin::Pin<&Self>, index: u32) -> sp::SharedString {
|
||||
fn item_element_infos(self: ::core::pin::Pin<&Self>, index: u32) -> sp::Option<sp::SharedString> {
|
||||
#![allow(unused)]
|
||||
let _self = self;
|
||||
match index {
|
||||
|
@ -1628,8 +1628,13 @@ fn generate_item_tree(
|
|||
self: ::core::pin::Pin<&Self>,
|
||||
index: u32,
|
||||
result: &mut sp::SharedString,
|
||||
) {
|
||||
*result = self.item_element_infos(index);
|
||||
) -> bool {
|
||||
if let Some(infos) = self.item_element_infos(index) {
|
||||
*result = infos;
|
||||
true
|
||||
} else {
|
||||
false
|
||||
}
|
||||
}
|
||||
|
||||
fn window_adapter(
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue