[GRASS-dev] [grass-code P][515] Close any open gis.m windows on GRASS exit

Glynn Clements glynn at gclements.plus.com
Fri Oct 19 09:39:37 EDT 2007


grass-dev at grass.itc.it wrote:

> code P item #515, was opened at 2007-10-19 15:02
> Status: Open
> Priority: 3
> Submitted By: M�ris Nartišs (marisn)
> Assigned to: Nobody (None)
> Summary: Close any open gis.m windows on GRASS exit 
> Patch status: None
> Patch type: enhancement
> GRASS component: gis.m
> GRASS version: CVS HEAD
> GRASS CVS checkout date, if applies (YYMMDD): 

Here's the patch:

Index: lib/init/init.sh
===================================================================
RCS file: /home/grass/grassrepository/grass6/lib/init/init.sh,v
retrieving revision 1.120
diff -u -u -r1.120 init.sh
--- lib/init/init.sh	6 Oct 2007 05:04:58 -0000	1.120
+++ lib/init/init.sh	19 Oct 2007 12:01:27 -0000
@@ -947,6 +947,16 @@
     d.mon stop=$MON 
 done
 
+
+if [ $TCLTKGRASSBASE ] ; then
+	# [ $TCLTKGRASSBASE && !$MINGW && !$CGWIN ] - send does NOT work on windows.
+	echo "Closing open gis.m sessions....."
+	echo 'foreach gwin [lsearch -all -inline [winfo interps] gm_tcl_$env(GIS_LOCK)*] {
+	catch {send -async $gwin exit}
+	}
+	exit' | $GRASS_WISH >/dev/null 2>&1
+fi
+
 echo "Cleaning up temporary files....."
 
 "$ETC/clean_temp" > /dev/null
Index: gui/tcltk/gis.m/gis.m
===================================================================
RCS file: /home/grass/grassrepository/grass6/gui/tcltk/gis.m/gis.m,v
retrieving revision 1.10
diff -u -u -r1.10 gis.m
--- gui/tcltk/gis.m/gis.m	9 May 2007 23:20:50 -0000	1.10
+++ gui/tcltk/gis.m/gis.m	19 Oct 2007 12:01:28 -0000
@@ -12,9 +12,9 @@
 
 if [ $# -eq 0 ] ; then
 #	if [ "$HOSTTYPE" = "macintosh" -o "$HOSTTYPE" = "powermac" -o "$HOSTTYPE" = "powerpc" -o "$HOSTTYPE" = "intel-pc" ] ; then
-#		exec "$GRASS_WISH" "$GISBASE/etc/gm/gm.tcl" -name gm_tcl
+#		exec "$GRASS_WISH" "$GISBASE/etc/gm/gm.tcl" -name gm_tcl_$GIS_LOCK
 #	else
-   		exec "$GRASS_WISH" "$GISBASE/etc/gm/gm.tcl" -name gm_tcl &
+   		exec "$GRASS_WISH" "$GISBASE/etc/gm/gm.tcl" -name gm_tcl_$GIS_LOCK &
 #   	fi
 	exit
 fi
@@ -23,4 +23,4 @@
   exec g.parser "$0" "$@"
 fi
 
-exec "$GRASS_WISH" "$GISBASE/etc/gm/gm.tcl" -name gm_tcl "$GIS_OPT_DMRC" sh &
+exec "$GRASS_WISH" "$GISBASE/etc/gm/gm.tcl" -name gm_tcl_$GIS_LOCK "$GIS_OPT_DMRC" sh &

> Initial Comment:
> This patch does two things:
> 1) Every gis.m app gets GRASS session ID encoded in it's name;

Encoding the session PID in the application name prevents users from
setting X resources specific to gis.m.

I suggest moving the session check into gis.m itself, e.g. adding the
following to gis.m:

	proc exitif {session_id} {
		global env
		if {$env(GIS_LOCK) == $session_id} exit
	}

and changing the init.sh code to:

	foreach gwin [lsearch -all -inline [winfo interps] gm_tcl*] {
		catch {send -async $gwin exitif $env(GIS_LOCK)}
	}

> 2) On exit, all gis.m windows with current session ID gets closed.
> 
> What needs to be tested:
> what will happen on windows? Somebody with Cygwin and MinGW versions please test it.

+	# [ $TCLTKGRASSBASE && !$MINGW && !$CGWIN ] - send does NOT work on windows.

Note that send doesn't work on some current Linux systems either, due
to X security mechanisms.

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




More information about the grass-dev mailing list