Skip to content

grass.script: Remove the saved region of a nested RegionManager - #757

Open
echoix wants to merge 2 commits into
mainfrom
region-manager-nested
Open

echoix wants to merge 2 commits into
mainfrom
region-manager-nested

Conversation

@echoix

@echoix echoix commented Oct 28, 2026 •

Copy link
Copy Markdown
Owner

Description

RegionManager.deactivate() removed the region it saved only when no WIND_OVERRIDE was set before activation, because the g.remove call was in the else branch. A nested RegionManager found the region of the outer one, restored it, and left its own region in the mapset. The region is now removed in both cases, like MaskManager does with its mask.

Two tests are added: the region saved by a RegionManager is removed, also when RegionManagers are nested.

Motivation and context

Deleting the g.remove call did not make any existing test fail, which showed that nothing checked the removal. A test for it found the leak with nesting.

How has this been tested?

The new tests pass, and test_region_manager_nested_removes_temporary_regions fails without the fix. Ruff check and format pass for the changed files.

Types of changes

  • Bug fix (non-breaking change which fixes an issue)

Checklist

  • PR title provides summary of the changes and starts with one of the
    pre-defined prefixes
  • My code follows the code style
    of this project.
  • My change requires a change to the documentation.
  • I have updated the documentation accordingly.
  • I have added tests to cover my changes.

The tests were written with AI assistance, and the expected values were checked against the behavior of the code.

RegionManager.deactivate() removed the region it saved only when no
WIND_OVERRIDE was set before activation. In a nested RegionManager the
inner one found the region of the outer one, restored it, and left its
own region in the mapset. Remove the saved region in both cases, like
MaskManager does with its mask.

Add tests that the region saved by a RegionManager is removed, also when
RegionManagers are nested.

Found by checking whether the tests detect the removal of the g.remove
call, using mutation testing and AI assistance.
@echoix
echoix force-pushed the region-manager-nested branch from 6f2a52c to 7901d86 Compare October 30, 2026 02:25
Check whether a region exists with g.findfile instead of searching the
list of regions for a name prefix. Also check that both nested regions
exist before they are removed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants