mirror of
https://github.com/slint-ui/slint.git
synced 2025-08-03 18:29:09 +00:00
Fix regression with empty array
Regression noticed in this line:
3f97d98bff/ui/tabs/downloads.slint (L77)
The following used to work:
```slint
import { Button, VerticalBox } from "std-widgets.slint";
export component Demo {
in property <[int]> mods;
VerticalBox {
alignment: start;
for xxx in true ? mods : [] : HorizontalLayout { alignment: center; Button { text: "OK!"; } }
}
}
```
But we fixed array conversion and this caused a regression with empty
array
This commit is contained in:
parent
2176523e4f
commit
ac8fd60091
4 changed files with 37 additions and 8 deletions
|
@ -517,6 +517,15 @@ public:
|
|||
}
|
||||
};
|
||||
|
||||
// Specialize for the empty array. We can't have a Model<void>, but `int` will work for our purpose
|
||||
template<>
|
||||
class ArrayModel<0, void> : public Model<int>
|
||||
{
|
||||
public:
|
||||
size_t row_count() const override { return 0; }
|
||||
std::optional<int> row_data(size_t) const override { return {}; }
|
||||
};
|
||||
|
||||
/// Model to be used when we just want to repeat without data.
|
||||
struct UIntModel : Model<int>
|
||||
{
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue