mirror of
https://github.com/slint-ui/slint.git
synced 2025-09-27 12:29:41 +00:00
Implement releasing of graphics resources in C++ via the component destructor
This commit is contained in:
parent
fb5a82b6c7
commit
55888afb1c
2 changed files with 35 additions and 13 deletions
|
@ -59,9 +59,11 @@ struct ComponentWindow
|
|||
sixtyfps_component_window_set_scale_factor(&inner, value);
|
||||
}
|
||||
|
||||
void free_graphics_resources(const VRef<ComponentVTable> &c) const
|
||||
template<typename Component>
|
||||
void free_graphics_resources(Component *c) const
|
||||
{
|
||||
internal::sixtyfps_component_window_free_graphics_resources(&inner, c);
|
||||
internal::sixtyfps_component_window_free_graphics_resources(
|
||||
&inner, VRef<ComponentVTable> { &Component::component_type, c });
|
||||
}
|
||||
|
||||
private:
|
||||
|
@ -176,10 +178,8 @@ struct Repeater
|
|||
std::vector<std::unique_ptr<C>> data;
|
||||
|
||||
template<typename Parent>
|
||||
void update_model(Model *model, const Parent *parent, const ComponentWindow *window) const
|
||||
void update_model(Model *model, const Parent *parent) const
|
||||
{
|
||||
for (size_t i = 0; i < data.size(); ++i)
|
||||
window->free_graphics_resources(item_at(i));
|
||||
auto &data = const_cast<Repeater *>(this)->data;
|
||||
data.clear();
|
||||
auto count = model->count();
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue