Fix KeyError when deleting or renaming a coordinate system - #23
Open
BrennanTM wants to merge 1 commit into
Open
Conversation
Session._onCoordinateSystemsChanged looked up every signaled key without guarding for deletions/renames, but the collection emits sigItemsChanged after the old key is removed. Guard with try/except KeyError, treating a missing key as a persistable change and flagging the session dirty. Note this handler is the sole dirty-flagger for coordinateSystems (unlike the similarly-guarded _onSamplesChanged, whose dirty flagging happens in a separate unconditional connection), so a missing key breaks-to-dirty rather than continuing.
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.
What broke —
Session._onCoordinateSystemsChangedindexedself.coordinateSystems[key]unguarded, but the collection emitssigItemsChangedafter removing the old key on delete/rename →KeyErroron both.Fix —
try/except KeyError; a missing key counts as a persistable change and marks the session dirty (this handler is the only dirty-flagger forcoordinateSystems). Autogeneration only callssetItem, so no spurious dirty flags there.Tests —
tests/test_Model/test_coordinateSystemsSessionHandling.py(2).Related, not fixed here —
AffineTransformedCoordinateSystemcan't be serialized (masked because affine systems are autogenerated and swapped for placeholders before save); see #16.