From ff0bb80105267120e0ec551787efdba7b9455bab Mon Sep 17 00:00:00 2001 From: Olivier Goffart Date: Fri, 30 Jun 2023 11:00:06 +0200 Subject: [PATCH] Fix computation of the item sub range We need to account for the repeater count in the item sub-range (cherry picked from commit e04835d209225f9a306979c633cd42cfbbff1c5f) --- internal/compiler/generator/cpp.rs | 1 + internal/compiler/generator/rust.rs | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/internal/compiler/generator/cpp.rs b/internal/compiler/generator/cpp.rs index 90374f53a5c..c26b7e4293e 100644 --- a/internal/compiler/generator/cpp.rs +++ b/internal/compiler/generator/cpp.rs @@ -1824,6 +1824,7 @@ fn generate_sub_component( "}} else if (index >= {} && index < {}) {{", sub.index_of_first_child_in_tree, sub.index_of_first_child_in_tree + sub_items_count - 1 + + sub.ty.repeater_count() )); code.push(format!( " return self->{}.{name}(index - {}{forward_args});", diff --git a/internal/compiler/generator/rust.rs b/internal/compiler/generator/rust.rs index 680f745fae7..d0762fe2a9e 100644 --- a/internal/compiler/generator/rust.rs +++ b/internal/compiler/generator/rust.rs @@ -872,7 +872,7 @@ fn generate_sub_component( )); if sub_items_count > 1 { let range_begin = local_index_of_first_child as usize; - let range_end = range_begin + sub_items_count - 2; + let range_end = range_begin + sub_items_count - 2 + sub.ty.repeater_count(); accessible_role_branch.push(quote!( #range_begin..=#range_end => #sub_compo_field.apply_pin(_self).accessible_role(index - #range_begin + 1), ));