Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJulian Eisel <julian@blender.org>2021-10-05 17:01:01 +0300
committerJulian Eisel <julian@blender.org>2021-10-05 17:10:27 +0300
commit758f3f7456ac1e31f411c4ac1b19760ad6e5539c (patch)
tree6250d84f5f188b887d3c2014ceeab5c619f3b0e8 /source/blender/editors/space_file/asset_catalog_tree_view.cc
parentdbe3981b0a805c1a40f42f57dc7ccc3d28270fda (diff)
Fix T91940: Asset Browser catalogs continuously redraw
Issue was that the `on_activate()` callback of tree-items were continuously called, because the active-state was queried before we fully reconstructed the tree and its state from the previous redraw. Such issues could happen in more places, so I've refactored the API a bit to reflect the requirements for state queries, and include some sanity checks. The actual fix for the issue is to delay the state change until the tree is fully reconstructed, by letting the tree-items pass a callback to check if they should be active.
Diffstat (limited to 'source/blender/editors/space_file/asset_catalog_tree_view.cc')
-rw-r--r--source/blender/editors/space_file/asset_catalog_tree_view.cc15
1 files changed, 5 insertions, 10 deletions
diff --git a/source/blender/editors/space_file/asset_catalog_tree_view.cc b/source/blender/editors/space_file/asset_catalog_tree_view.cc
index ff8775155c2..291582dac08 100644
--- a/source/blender/editors/space_file/asset_catalog_tree_view.cc
+++ b/source/blender/editors/space_file/asset_catalog_tree_view.cc
@@ -151,9 +151,7 @@ ui::BasicTreeViewItem &AssetCatalogTreeView::build_catalog_items_recursive(
{
ui::BasicTreeViewItem &view_item = view_parent_item.add_tree_item<AssetCatalogTreeViewItem>(
&catalog);
- if (is_active_catalog(catalog.get_catalog_id())) {
- view_item.activate();
- }
+ view_item.is_active([this, &catalog]() { return is_active_catalog(catalog.get_catalog_id()); });
catalog.foreach_child([&view_item, this](AssetCatalogTreeItem &child) {
build_catalog_items_recursive(view_item, child);
@@ -171,9 +169,8 @@ void AssetCatalogTreeView::add_all_item()
params->asset_catalog_visibility = FILE_SHOW_ASSETS_ALL_CATALOGS;
WM_main_add_notifier(NC_SPACE | ND_SPACE_ASSET_PARAMS, nullptr);
});
- if (params->asset_catalog_visibility == FILE_SHOW_ASSETS_ALL_CATALOGS) {
- item.activate();
- }
+ item.is_active(
+ [params]() { return params->asset_catalog_visibility == FILE_SHOW_ASSETS_ALL_CATALOGS; });
}
void AssetCatalogTreeView::add_unassigned_item()
@@ -187,10 +184,8 @@ void AssetCatalogTreeView::add_unassigned_item()
params->asset_catalog_visibility = FILE_SHOW_ASSETS_WITHOUT_CATALOG;
WM_main_add_notifier(NC_SPACE | ND_SPACE_ASSET_PARAMS, nullptr);
});
-
- if (params->asset_catalog_visibility == FILE_SHOW_ASSETS_WITHOUT_CATALOG) {
- item.activate();
- }
+ item.is_active(
+ [params]() { return params->asset_catalog_visibility == FILE_SHOW_ASSETS_WITHOUT_CATALOG; });
}
bool AssetCatalogTreeView::is_active_catalog(CatalogID catalog_id) const