#14192 Python: Fix duplicate discrete property legend on repeated cat…#14199
Merged
Conversation
kriben
marked this pull request as ready for review
June 10, 2026 10:31
magnesj
requested changes
Jun 10, 2026
magnesj
left a comment
Member
There was a problem hiding this comment.
If a view is using the color legend connected to this list of property names, the view will change colors to an undefined color legend after the function call. I suggest updating the color legend instead of delete/create.
…egory-name calls RimColorLegendCollection::deleteColorLegend erased the default-legend map entry before looking the legend up, so findDefaultLegendForResult always returned null and the old legend was never removed from m_customColorLegends. Each set_discrete_property_category_names call for the same property left an orphaned legend behind and appended a new one. Look up the legend before erasing the map key, and guard against deleting a standard legend that may have been registered as a default.
… of delete/create Address review feedback on #14199: deleting and recreating the legend left views bound to the old legend pointing at a deleted object. Add RimColorLegendCollection::updateColorLegend and a matching UpdateColorLegend scriptable method that mutate the existing custom legend (name and items) so referring views keep their binding and are notified once. A new legend is only created when none is registered for the result or the registered legend is a standard legend. set_discrete_property_category_names now performs a single atomic call instead of delete + create + per-item appends. The empty-dict removal path still uses DeleteColorLegend.
Reuse RimColorLegendCollection::updateColorLegend in the two roff import sites that previously deleted and recreated the legend bound to a result, so views referencing the legend keep their binding on re-import. Extract the rock color matching from createColorLegendMatchDefaultRockColors into matchDefaultRockColors so the facies branch can pass matched colors to updateColorLegend. Remove the now-unused RimColorLegendCollection::createColorLegend.
kriben
force-pushed
the
14192-fix-duplicate-discrete-property-legend
branch
from
June 10, 2026 14:53
f74e9b8 to
e70d9ff
Compare
magnesj
approved these changes
Jun 10, 2026
magnesj
approved these changes
Jun 10, 2026
magnesj
pushed a commit
that referenced
this pull request
Jun 10, 2026
… of delete/create Address review feedback on #14199: deleting and recreating the legend left views bound to the old legend pointing at a deleted object. Add RimColorLegendCollection::updateColorLegend and a matching UpdateColorLegend scriptable method that mutate the existing custom legend (name and items) so referring views keep their binding and are notified once. A new legend is only created when none is registered for the result or the registered legend is a standard legend. set_discrete_property_category_names now performs a single atomic call instead of delete + create + per-item appends. The empty-dict removal path still uses DeleteColorLegend.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
…egory-name calls
RimColorLegendCollection::deleteColorLegend erased the default-legend map entry before looking the legend up, so findDefaultLegendForResult always returned null and the old legend was never removed from m_customColorLegends. Each set_discrete_property_category_names call for the same property left an orphaned legend behind and appended a new one.
Look up the legend before erasing the map key, and guard against deleting a standard legend that may have been registered as a default.
Fixes #14192.