[GRASS-dev] [GRASS GIS] #3896: d.legend: error when displaying raster legend

#3896: d.legend: error when displaying raster legend
-------------------------+---------------------------------
Reporter: veroandreo | Owner: grass-dev@…
     Type: defect | Status: new
Priority: normal | Milestone: 7.8.0
Component: Display | Version: git-releasebranch78
Keywords: d.legend | CPU: Unspecified
Platform: Unspecified |
-------------------------+---------------------------------
When calling G7:d.legend from terminal for a wx monitor, the legend is not
displayed and I get the following error in the terminal:

{{{
Traceback (most recent call last):
   File "/usr/lib64/python3.7/site-packages/wx/core.py", line 2228, in
Notify
     self.notify()
   File "/home/veroandreo/software/grass78_git/dist.x86_64-pc-linux-
gnu/gui/wxpython/mapdisp/main.py", line 592, in watcher
     self.mapFrm.GetMap().GetLayersFromCmdFile()
   File "/home/veroandreo/software/grass78_git/dist.x86_64-pc-linux-
gnu/gui/wxpython/mapdisp/main.py", line 203, in GetLayersFromCmdFile
     self._giface.GetMapDisplay().AddLegendRast(cmd=cmd)
   File "/home/veroandreo/software/grass78_git/dist.x86_64-pc-linux-
gnu/gui/wxpython/mapdisp/frame.py", line 1244, in AddLegendRast
     cmd, completed=(self.GetOptData, None, None))
   File "/home/veroandreo/software/grass78_git/dist.x86_64-pc-linux-
gnu/gui/wxpython/gui_core/forms.py", line 2925, in ParseCommand
     get_dcmd=get_dcmd, layer=layer)
   File "/home/veroandreo/software/grass78_git/dist.x86_64-pc-linux-
gnu/gui/wxpython/gui_core/forms.py", line 550, in __init__
     frame=self)
   File "/home/veroandreo/software/grass78_git/dist.x86_64-pc-linux-
gnu/gui/wxpython/gui_core/forms.py", line 1454, in __init__
     for layer in layers:
TypeError: iter() returned non-iterator of type 'LayerList'
}}}

If I use the main GUI though, all seems to work fine, no errors in the
console tab.

--
Ticket URL: <https://trac.osgeo.org/grass/ticket/3896&gt;
GRASS GIS <https://grass.osgeo.org>

#3896: d.legend: error when displaying raster legend
--------------------------+---------------------------------
  Reporter: veroandreo | Owner: grass-dev@…
      Type: defect | Status: new
  Priority: normal | Milestone: 7.8.0
Component: Display | Version: git-releasebranch78
Resolution: | Keywords: d.legend
       CPU: Unspecified | Platform: Unspecified
--------------------------+---------------------------------

Comment (by annakrat):

Should be fixed in master. Please test, needs backport.

--
Ticket URL: <https://trac.osgeo.org/grass/ticket/3896#comment:1&gt;
GRASS GIS <https://grass.osgeo.org>

#3896: d.legend: error when displaying raster legend
--------------------------+---------------------------------
  Reporter: veroandreo | Owner: grass-dev@…
      Type: defect | Status: new
  Priority: normal | Milestone: 7.8.0
Component: Display | Version: git-releasebranch78
Resolution: | Keywords: d.legend
       CPU: Unspecified | Platform: Unspecified
--------------------------+---------------------------------

Comment (by neteler):

Fix GH cdb2ad31bf56173e6c7782600664c9ece63bd14b solved it.

I have backported it to relbr78.

--
Ticket URL: <https://trac.osgeo.org/grass/ticket/3896#comment:2&gt;
GRASS GIS <https://grass.osgeo.org>

#3896: d.legend: error when displaying raster legend
--------------------------+---------------------------------
  Reporter: veroandreo | Owner: grass-dev@…
      Type: defect | Status: new
  Priority: normal | Milestone: 7.8.0
Component: Display | Version: git-releasebranch78
Resolution: | Keywords: d.legend
       CPU: Unspecified | Platform: Unspecified
--------------------------+---------------------------------

Comment (by veroandreo):

The reported error with d.legend seems to be gone, but if I run the
commands in the following order:

{{{
d.mon wx0
d.rast elevation
d.barscale
d.northarrow
d.legend raster=elevation
}}}

d.legend makes the raster map disappear... I have to re-render to have it
back... that shouldn't be the expected behavior, IMO

Same happens if I do:

{{{
d.mon wx0
d.rast elevation
d.barscale
d.northarrow
d.legend raster=elevation
}}}

Seems that there's still something messed up with the layers being
displayed

--
Ticket URL: <https://trac.osgeo.org/grass/ticket/3896#comment:3&gt;
GRASS GIS <https://grass.osgeo.org>

#3896: d.legend: error when displaying raster legend
--------------------------+---------------------------------
  Reporter: veroandreo | Owner: grass-dev@…
      Type: defect | Status: new
  Priority: normal | Milestone: 7.8.0
Component: Display | Version: git-releasebranch78
Resolution: | Keywords: d.legend
       CPU: Unspecified | Platform: Unspecified
--------------------------+---------------------------------

Comment (by veroandreo):

Ops, last one is a copy-paste problem... The order of commands was
different, but now I'm no longer with the laptop.

--
Ticket URL: <https://trac.osgeo.org/grass/ticket/3896#comment:4&gt;
GRASS GIS <https://grass.osgeo.org>

#3896: d.legend: error when displaying raster legend
--------------------------+---------------------------------
  Reporter: veroandreo | Owner: grass-dev@…
      Type: defect | Status: new
  Priority: normal | Milestone: 7.8.0
Component: Display | Version: git-releasebranch78
Resolution: | Keywords: d.legend
       CPU: Unspecified | Platform: Unspecified
--------------------------+---------------------------------

Comment (by annakrat):

I can't reproduce this, it works ok.

--
Ticket URL: <https://trac.osgeo.org/grass/ticket/3896#comment:5&gt;
GRASS GIS <https://grass.osgeo.org>

#3896: d.legend: error when displaying raster legend
--------------------------+---------------------------------
  Reporter: veroandreo | Owner: grass-dev@…
      Type: defect | Status: new
  Priority: normal | Milestone: 7.8.1
Component: Display | Version: git-releasebranch78
Resolution: | Keywords: d.legend
       CPU: Unspecified | Platform: Unspecified
--------------------------+---------------------------------

Comment (by veroandreo):

Replying to [comment:3 veroandreo]:
> The reported error with d.legend seems to be gone, but if I run the
commands in the following order:
>
> {{{
> d.mon wx0
> d.rast elevation
> d.barscale
> d.northarrow
> d.legend raster=elevation
> }}}
>
> d.legend makes the raster map disappear... I have to re-render to have
it back... that shouldn't be the expected behavior, IMO

I updated and recompiled 78 and also my system, but I still observe the
same behaviour. No idea.

--
Ticket URL: <https://trac.osgeo.org/grass/ticket/3896#comment:7&gt;
GRASS GIS <https://grass.osgeo.org>

#3896: d.legend: error when displaying raster legend
--------------------------+---------------------------------
  Reporter: veroandreo | Owner: grass-dev@…
      Type: defect | Status: new
  Priority: normal | Milestone: 7.8.1
Component: Display | Version: git-releasebranch78
Resolution: | Keywords: d.legend
       CPU: Unspecified | Platform: Unspecified
--------------------------+---------------------------------

Comment (by neteler):

Just checked on my system with a freshly compiled 7.8.dev: `d.northarrow`
makes the raster map disappear (using the example above). The other map
elements remain!

{{{
GRASS 7.8.1dev (nc_spm_08):~ > g.version -rge
version=7.8.1dev
date=2019
revision=e2f0c65c9
build_date=2019-10-29
build_platform=x86_64-pc-linux-gnu
build_off_t_size=8
libgis_revision=00000
libgis_date="?"
proj=5.2.0
gdal=2.3.2
geos=3.7.1
sqlite=3.26.0
}}}

Does it work on Windows?

--
Ticket URL: <https://trac.osgeo.org/grass/ticket/3896#comment:8&gt;
GRASS GIS <https://grass.osgeo.org>

#3896: d.legend: error when displaying raster legend
--------------------------+---------------------------------
  Reporter: veroandreo | Owner: grass-dev@…
      Type: defect | Status: new
  Priority: normal | Milestone: 7.8.1
Component: Display | Version: git-releasebranch78
Resolution: | Keywords: d.legend
       CPU: Unspecified | Platform: Unspecified
--------------------------+---------------------------------

Comment (by neteler):

I tested again, the updated PR works fine for me in master (Fedora 30).

--
Ticket URL: <https://trac.osgeo.org/grass/ticket/3896#comment:9&gt;
GRASS GIS <https://grass.osgeo.org>

#3896: d.legend: error when displaying raster legend
--------------------------+---------------------------------
  Reporter: veroandreo | Owner: grass-dev@…
      Type: defect | Status: new
  Priority: normal | Milestone: 7.8.1
Component: Display | Version: git-releasebranch78
Resolution: | Keywords: d.legend
       CPU: Unspecified | Platform: Unspecified
--------------------------+---------------------------------

Comment (by annakrat):

Merged and backported. Since the problem remains for Vero, I will keep
this open.

--
Ticket URL: <https://trac.osgeo.org/grass/ticket/3896#comment:10&gt;
GRASS GIS <https://grass.osgeo.org>