Skip to content

Fix bug where AddNewLayer() emitted a LayerAdded event with the wrong index#2150

Merged
cameronwhite merged 1 commit into
masterfrom
fix/layer-event-index
May 10, 2026
Merged

Fix bug where AddNewLayer() emitted a LayerAdded event with the wrong index#2150
cameronwhite merged 1 commit into
masterfrom
fix/layer-event-index

Conversation

@cameronwhite
Copy link
Copy Markdown
Member

The event was always fired with the index of the topmost layer, which is wrong if a different layer is selected. Also refactored a bit so that this method updates the selected layer and emits an event for the selection change , to be consistent with DuplicateLayer()

Since the layers list view uses this index to create list items which hold a reference to the UserLayer, the new item in the list would be referencing the wrong layer. In the bug report, this was why the third layer showed up with the name "Layer 2" rather than "Layer 3", and eventually led to the crash after layer 2 was removed.

Fixes: #2129

… index.

The event was always fired with the index of the topmost layer, which is wrong if a different layer is selected.
Also refactored a bit so that this method updates the selected layer and emits an event for the selection change , to be consistent with DuplicateLayer()

Since the layers list view uses this index to create list items which hold a reference to the UserLayer, the new item in the list would be referencing the wrong layer. In the bug report, this was why the third layer showed up with the name "Layer 2" rather than "Layer 3", and eventually led to the crash after layer 2 was removed.

Fixes: #2129
@cameronwhite cameronwhite merged commit a4d3490 into master May 10, 2026
11 checks passed
@cameronwhite cameronwhite deleted the fix/layer-event-index branch May 10, 2026 20:26
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.

Unhandled exception when delete a layer

1 participant