Opened 11 years ago
Closed 5 years ago
#2173 closed defect (wontfix)
Tcl NVIZ: load state file "Error: must be surf_id set_mask_mode BOOLEAN"
Reported by: | hamish | Owned by: | |
---|---|---|---|
Priority: | major | Milestone: | 6.5.0 |
Component: | Tcl/Tk NVIZ | Version: | svn-develbranch6 |
Keywords: | load state, raster | Cc: | |
CPU: | x86-64 | Platform: | Linux |
Description
Hi,
there is a bug in writing the saved-state file in tcl/tk NVIZ. It means that re-loading a state file with raster layers leads to an inconsistent internal state.
The reason is the mask-map inversion status being written as "00" not "0". Fixing the file by hand solves the issue and lets you load the state file correctly.
spearfish example:
GRASS> g.region -d GRASS> nviz elev=elevation.dem File --> Save State Save as "test.nviz" GRASS> head -n 27 test.nviz | tail -n 17 surf*1390794941 map elevation.dem 0 map elevation.dem 0 unset 00 unset const 60.000000 unset #888888 0.000000 0.000000 0.000000 3 3 2 2 poly grid_surf gouraud GRASS> nviz state=test.nviz Loading raster map <elevation.dem@PERMANENT>... 100% Loading raster map <elevation.dem@PERMANENT>... 100% Translating colors from raster map <elevation.dem@PERMANENT>... 100% Diagnostic: Error: must be surf_id set_mask_mode BOOLEAN -- Load procedure for panel >>>start surf may not be defined
And the internal state becomes a bit messed up: The surface renders but the Raster Surfaces controls show none loaded.
In map_obj.c set_mask_mode() fails because it is saved in the file as "00" not "0" (7th line of the 'surf' entry).
The code that creates it is get_mask_mode() in visualization/nviz/src/map_obs.c, but that is using sprintf(tmp, "%d", mode);
to create the string so I'm not seeing where/how the "00" is being introduced, since %d should lead to just "0".
?
The work-around is to edit the .nviz state file by hand and change the "00" to "0". Then the "Load State" works as expected.
Interestingly the first time I launch tcl nviz in 6.4.3 on a different machine it wrote out "0" but later attempts following the exact same series of clicks writes out "00".. smashed stack?
see also scripts/panel_surf.tcl for the reading and writing of the session-state file (Nviz_surf_save() is well commented).
Another question is if after fixing the source of the "00" trouble if we allow sloppy-read, i.e. to auto-translate 00 to 0 upon load so the user can load old+broken .nviz state files created by this bug. Or as a general policy if keeping work-arounds in the code base for old bugs generates too much code-clutter? In this case I would suggest to err on the side of being kind to the victims.
thanks, Hamish
Replying to hamish:
sorry, my mistake. That happened when switching between 6.4.3 and 6.5, so the bug is in 6.5 only.
Hamish