瀏覽代碼

Prevent starting the same monitor multiple times.

d.mon start=wx0
d.mon start=wx1
d.mon start=wx0 # Creates another wx0 monitor rather than selecting the
		# existing one.



git-svn-id: https://svn.osgeo.org/grass/grass/trunk@60207 15284696-431f-4ddb-bdfa-cd5b030d7da7
Huidae Cho 11 年之前
父節點
當前提交
4bdb0e20a5
共有 1 個文件被更改,包括 11 次插入6 次删除
  1. 11 6
      display/d.mon/start.c

+ 11 - 6
display/d.mon/start.c

@@ -58,16 +58,21 @@ int start_mon(const char *name, const char *output, int select,
 	      int width, int height, const char *bgcolor,
 	      int truecolor)
 {
-    const char *curr_mon;
     char *u_name;
     char *env_name, *env_value, *cmd_value;
     char *tempfile, buf[1024];
     int env_fd;
-    
-    curr_mon = G__getenv("MONITOR");
-    if (curr_mon && strcmp(curr_mon, name) == 0 && check_mon(curr_mon))
-	G_fatal_error(_("Monitor <%s> already running"), name);
-    
+
+    if (check_mon(name)) {
+        const char *curr_mon;
+
+        curr_mon = G__getenv("MONITOR");
+	if (select && (!curr_mon || strcmp(curr_mon, name) != 0))
+	    G_setenv("MONITOR", name);
+
+        G_fatal_error(_("Monitor <%s> already running"), name);
+    }
+
     tempfile = G_tempfile();
 
     u_name = G_store_upper(name);