[GRASS-dev] v.digit startup error from -n position

Glynn Clements glynn at gclements.plus.com
Wed Aug 2 18:28:25 EDT 2006


Michael Barton wrote:

> OK. Looking through to the very bottom of the thread, there appears to be
> some confusion about what is meant by GUI.
> 
> If v.digit is having a problem with a new vector when run from the toolbar
> button in gism, it  is one thing. This SHOULD be OK. I've checked the code
> and it is written...
> 
>   v.digit -n map=new_map
> 
> ... as Glynn indicated. If this is where the problem lies, then, there is
> some other kind of issue.

Contrary to the "resolved" status in the RT, the real bug remains.

v.digit is calling Tk_Main() as:

    Tk_Main(argc, argv, Tcl_AppInit);

where argc/argv are those passed to main.

It shouldn't be doing this; it should be passing a dummy argv, e.g.

    char *fake_argv[2];
	...
    fake_argv[0] = argv[0];
    fake_argv[1] = NULL;
    Tk_Main(1, fake_argv, Tcl_AppInit);

Changing the order of v.digit's arguments is a workaround, not a fix.

> Glynn also noted, however, that in the auto-generated GUI dialogs, this is
> being written as...
> 
>   v.digit map=new_map -n
> 
> This causes a problem because the -n is misinterpreted by TclTk as a flag in
> the TclTk command. So if the problem arises when v.digit is run from a menu
> or the dialog is started from the CLI by simply typing v.digit, then THIS is
> where the problem lies.
> 
> Generically, the GRASS flags should come before any other arguments it
> seems. I don't know where this is coded, but Cedric should know.

The generate_tcl() function in lib/gis/parser.c writes out a list of
flags/options, with the flags last. gui.tcl passes the command-line
options to the module in their original order, i.e. with the flags
last.

This isn't a problem, as G_parser() doesn't care about the order. The
fact that putting the flags first happens to work around the bug in
v.digit is a coincidence, but not a particularly relevant one: v.digit
should still be fixed.

-- 
Glynn Clements <glynn at gclements.plus.com>




More information about the grass-dev mailing list