Skip to content

#14192 Python: Fix duplicate discrete property legend on repeated cat…#14199

Merged
magnesj merged 3 commits into
devfrom
14192-fix-duplicate-discrete-property-legend
Jun 10, 2026
Merged

#14192 Python: Fix duplicate discrete property legend on repeated cat…#14199
magnesj merged 3 commits into
devfrom
14192-fix-duplicate-discrete-property-legend

Conversation

@kriben

@kriben kriben commented Jun 10, 2026

Copy link
Copy Markdown
Collaborator

…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.

@kriben
kriben marked this pull request as ready for review June 10, 2026 10:31

@magnesj magnesj left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

kriben added 3 commits June 10, 2026 13:45
…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
kriben force-pushed the 14192-fix-duplicate-discrete-property-legend branch from f74e9b8 to e70d9ff Compare June 10, 2026 14:53
@kriben
kriben requested a review from magnesj June 10, 2026 15:10
@magnesj
magnesj merged commit d78d7cf into dev Jun 10, 2026
21 checks passed
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.
@magnesj
magnesj deleted the 14192-fix-duplicate-discrete-property-legend branch June 10, 2026 16:02
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

python: Duplicate discrete property legend

2 participants