From 6207f97087bb5da44910f386d05ceba685bde2a9 Mon Sep 17 00:00:00 2001 From: John Haddon Date: Fri, 5 Jul 2024 10:58:27 +0100 Subject: [PATCH] PathListingWidget : Avoid blocking UI in `setPath( rootPath )` The root path is the only path that we ever display in fundamental UIs like the HierarchyView and RenderPassEditor. In this case we were needlessly invoking `Path.isLeaf()` and `Path.isValid()` on the UI thread, causing ScenePath and RenderPassPath to trigger arbitrary computation that could block the UI until complete. By taking an early-out for the root path can completely avoid that, with all the remaining work all happening in a BackgroundTask. --- Changes.md | 1 + python/GafferUI/PathListingWidget.py | 12 +++++++----- 2 files changed, 8 insertions(+), 5 deletions(-) diff --git a/Changes.md b/Changes.md index 8e0a511ed2b..07a11fb376d 100644 --- a/Changes.md +++ b/Changes.md @@ -18,6 +18,7 @@ Improvements - The `data_seed`, `proc_seed`, `obj_seed`, and `face_seed` parameters of the `color_jitter` shader. - EditScope : Added summaries of set membership edits in the NodeEditor. - LightEditor : Mute and solo columns now accurately reflect the presence of the `light:mute` attribute (for the Mute column) and membership in the `soloLights` set (for the Solo column) for all scene locations, not just for lights. +- HierarchyView, LightEditor, RenderPassEditor, SetEditor : Reduced potential UI stalls when first showing a scene. Fixes ----- diff --git a/python/GafferUI/PathListingWidget.py b/python/GafferUI/PathListingWidget.py index f9c609db281..ea5774c6c4e 100644 --- a/python/GafferUI/PathListingWidget.py +++ b/python/GafferUI/PathListingWidget.py @@ -477,6 +477,9 @@ def __update( self ) : def __dirPath( self ) : p = self.__path.copy() + if not len( p ) : + return p + if p.isLeaf() : # if it's a leaf then take the parent del p[-1] @@ -486,11 +489,10 @@ def __dirPath( self ) : # it's not valid. if we can make it # valid by trimming the last element # then do that - if len( p ) : - pp = p.copy() - del pp[-1] - if pp.isValid() : - p = pp + pp = p.copy() + del pp[-1] + if pp.isValid() : + p = pp else : # it's valid and not a leaf, and # that's what we want.