Opened 16 years ago

Closed 15 years ago

#534 closed defect (fixed)

g.gui doesn't work in ms-windows

Reported by: cnielsen Owned by: grass-dev@…
Priority: major Milestone: 6.4.0
Component: wxGUI Version: svn-releasebranch64
Keywords: wingrass Cc: heshikik
CPU: Unspecified Platform: MSWindows XP

Description

From a self-compiled version (mingw/msys), or osgeo4w version, g.gui fails to restart the gui on windows. For the osgeo4w version I created a grass64 file and started from within an msys shell. No error messages appear in either case.

Fails to restart either the tcltk or wxpython gui

GRASS 6.4.0RC3 (Latlong):/d > g.gui wxpython
GRASS 6.4.0RC3 (Latlong):/d > 

Attachments (2)

g_gui_crash.jpg (40.6 KB ) - added by neteler 15 years ago.
g.gui crashing in WinGRASS in Japanese Windows-XP
mswin_python_set.diff (2.2 KB ) - added by hamish 15 years ago.
patch to set GRASS_PYTHON if it isn't already

Download all attachments as: .zip

Change History (19)

comment:1 by cnielsen, 16 years ago

Resolution: fixed
Status: newclosed

seems to be fixed

comment:2 by neteler, 15 years ago

Resolution: fixed
Status: closedreopened

comment:3 by neteler, 15 years ago

Version: unspecifiedsvn-releasebranch64

The problem persists on WindowsXP, Japanese version. See attachement.

by neteler, 15 years ago

Attachment: g_gui_crash.jpg added

g.gui crashing in WinGRASS in Japanese Windows-XP

comment:4 by neteler, 15 years ago

Component: defaultwxGUI

I tried with "tcltk" as parameter and it works. So the problem is "only" to launch "wxpython", in general g.gui.exe seems to be ok.

in reply to:  4 ; comment:5 by glynn, 15 years ago

Replying to neteler:

I tried with "tcltk" as parameter and it works. So the problem is "only" to launch "wxpython", in general g.gui.exe seems to be ok.

So the problem is with wxGUI, not g.gui? Does:

$GRASS_PYTHON $GISBASE/etc/wxpython/wxgui.py &

work?

in reply to:  5 comment:6 by glynn, 15 years ago

Replying to glynn:

Does:

$GRASS_PYTHON $GISBASE/etc/wxpython/wxgui.py &

work?

Duh; this is Windows; that should be:

"%GRASS_PYTHON%" "%WINGISBASE%\etc\wxpython\wxgui.py"

comment:7 by neteler, 15 years ago

Tested: the (simple) problem is that "%GRASS_PYTHON%" is not defined at all. When defining it manually (set GRASS_PYTHON=python), also g.gui works.

I see that the variable is defined in lib/init/init.sh but not in any .bat file.

comment:8 by heshikik, 15 years ago

Cc: heshikik added

in reply to:  7 comment:9 by hamish, 15 years ago

Replying to neteler:

I see that the variable is defined in lib/init/init.sh but not in any .bat file.

only by mswindows/osgeo4w/ini.bat.tmpl?

osgeo4w/ini.bat.tmpl:5:set GRASS_PYTHON=%OSGEO4W_ROOT%\bin\python.exe

Hamish

comment:10 by hamish, 15 years ago

testing on wingrass prev binary r40019-

from the "GRASS 6.4.SVN with MSYS" terminal prompt $GRASS_PYTHON is set (presumably by init.sh) and "g.gui wxpython" works.

from the "GRASS Command Line" menu item DOS-box %GRASS_PYTHON% is not set and "g.gui wxpython" fails unless I set it. It is best to fix init.bat of course, but perhaps we could also add a check to see if the getenv() in g.gui.c is empty, and if it is default to "python"?

Hamish

in reply to:  10 comment:11 by neteler, 15 years ago

Replying to hamish:

from the "GRASS Command Line" menu item DOS-box %GRASS_PYTHON% is not set and "g.gui wxpython" fails unless I set it. It is best to fix init.bat of course, but perhaps we could also add a check to see if the getenv() in g.gui.c is empty, and if it is default to "python"?

A default sounds good to me (just to "python") - if python is absent it would fail in any case.

Markus

by hamish, 15 years ago

Attachment: mswin_python_set.diff added

patch to set GRASS_PYTHON if it isn't already

comment:12 by hamish, 15 years ago

patch attached to this ticket vs. trunk to solve this in three different ways/places.

I'm a bit murky on the G_store() usage, so review before committing.

Hamish

comment:13 by hamish, 15 years ago

setting GRASS_PYTHON=python at the DOS prompt works.

I've committed to all branches the init.sh and grass.bat fixes from the patch. see svn r40435-7.

Putting a fail-safe in g.gui.c still needs to be decided but is not a blocker for release.

Hamish

comment:14 by hamish, 15 years ago

Keywords: wingrass added

comment:15 by hamish, 15 years ago

I'm a bit murky on the G_store() usage, so review.

svn diff trunk/general/g.gui/main.c
Index: main.c
===================================================================
--- main.c      (revision 40408)
+++ main.c      (working copy)
@@ -27,7 +27,7 @@
     struct Option *type, *rc_file;
     struct Flag *update, *nolaunch;
     struct GModule *module;
-    const char *gui_type_env;
+    const char *gui_type_env, *python_cmd;
     char progname[GPATH_MAX];
 
     G_gisinit(argv[0]);
@@ -103,14 +103,19 @@
 
     G_debug(1, "Attempting to start '%s' GUI ...", type->answer);
 
+    python_cmd = getenv("GRASS_PYTHON");
+
+    if(!python_cmd)
+       python_cmd = G_store("python");
+
     if (strcmp(type->answer, "wxpython") == 0) {
        sprintf(progname, "%s/etc/wxpython/wxgui.py", G_gisbase());
        if (rc_file->answer) {
-           G_spawn_ex(getenv("GRASS_PYTHON"), progname, progname,
+           G_spawn_ex(python_cmd, progname, progname,
                    "--workspace", rc_file->answer, SF_BACKGROUND, NULL);
        }
        else {
-           G_spawn_ex(getenv("GRASS_PYTHON"), progname, progname,
+           G_spawn_ex(python_cmd, progname, progname,
                    SF_BACKGROUND, NULL);
        }
     }

Hamish

in reply to:  13 comment:16 by glynn, 15 years ago

Replying to hamish:

Putting a fail-safe in g.gui.c still needs to be decided but is not a blocker for release.

It would also need to go into lib/gis/parser.c, g.mapsets/main.c, scripts/wxpyimgview/wxpyimgview.py, v.krige.py and d.rast.edit.py (when they eventually get fixed), and anything else which uses $GRASS_PYTHON.

IOW, it needs to be set in the startup scripts. Adding workarounds for specific cases is fixing the symptoms rather than the bug.

comment:17 by hamish, 15 years ago

Resolution: fixed
Status: reopenedclosed

ok, primary subject of bug is fixed on all platforms; adding multiple layers of redundancy to deal with missing GRASS_PYTHON and GRASS_WISH enviro variables will be a wontfix. we can reconsider that later if it ever becomes a real problem.

Hamish

Note: See TracTickets for help on using tickets.