Release graphics resources of items when deleting components in C++

This commit is contained in:
Simon Hausmann 2020-08-13 13:27:14 +02:00
parent b96b627a4f
commit d650cadc02
4 changed files with 23 additions and 3 deletions

View file

@ -59,6 +59,11 @@ struct ComponentWindow
sixtyfps_component_window_set_scale_factor(&inner, value);
}
void free_graphics_resources(const VRef<ComponentVTable> &c) const
{
internal::sixtyfps_component_window_free_graphics_resources(&inner, c);
}
private:
internal::ComponentWindowOpaque inner;
};
@ -171,8 +176,10 @@ struct Repeater
std::vector<std::unique_ptr<C>> data;
template<typename Parent>
void update_model(Model *model, const Parent *parent) const
void update_model(Model *model, const Parent *parent, const ComponentWindow *window) 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();