From bb6525600600076764a06eae603a722570428488 Mon Sep 17 00:00:00 2001 From: RAJVEER42 Date: Wed, 10 Jun 2026 01:02:35 +0530 Subject: [PATCH] r.earthworks: use a temporary region to restore the user's region on exit The finally block in main() registers cleanup of temporary maps but does not restore the computational region, so on an error between the region change and the series() restore the user could be left with a changed region. Wrap the region handling in gs.use_temp_region() so the original region is restored automatically on exit, including on error. --- src/raster/r.earthworks/r.earthworks.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/raster/r.earthworks/r.earthworks.py b/src/raster/r.earthworks/r.earthworks.py index f1933a3304..edaf4f7f51 100644 --- a/src/raster/r.earthworks/r.earthworks.py +++ b/src/raster/r.earthworks/r.earthworks.py @@ -1249,6 +1249,10 @@ def main(): # Run processes try: + # Use a temporary region so the user's computational region is + # restored on exit, including when the module exits with an error + gs.use_temp_region() + # Convert inputs if raster: coordinates = convert_raster(raster)