mirror of
https://github.com/slint-ui/slint.git
synced 2025-09-30 13:51:13 +00:00
Fix disappearing images or panics when hiding and showing a window with wayland
Properly release GL resource when unmapping a window and detect stale cache indices using a generation count. This fixes the disappearing images (GL textures would be invalid and need to be re-created) as well as the panics when an item's cache index ended up being re-used because some other item was drawn first and allocated that indices. The latter is fixed by using a generational counter on the cache that's bumped when clearing, instead of a single "cache_ok" bool.
This commit is contained in:
parent
9503ba69b3
commit
d4385280eb
4 changed files with 64 additions and 10 deletions
|
@ -112,10 +112,20 @@ impl ItemGraphicsCacheEntry {
|
|||
struct ItemGraphicsCache(RenderingCache<Option<ItemGraphicsCacheEntry>>);
|
||||
|
||||
impl ItemGraphicsCache {
|
||||
/// Convenience method for releasing an item's cached graphics data.
|
||||
fn release(&mut self, item_data: &CachedRenderingData) {
|
||||
item_data.release(&mut self.0);
|
||||
}
|
||||
|
||||
/// Clears the entire graphics cache. This is needed when for example loosing
|
||||
/// the GL context (when unmapping a window) and destroying the canvas.
|
||||
fn clear(&mut self) {
|
||||
self.0.clear();
|
||||
}
|
||||
|
||||
/// Convenience method that will return what's in the item's graphics cache
|
||||
/// and call update_fn if the cache is outdated and needs refreshing. If
|
||||
/// update_fn is called, the data is persisted in the cache.
|
||||
fn ensure_up_to_date(
|
||||
&mut self,
|
||||
item_data: &CachedRenderingData,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue