[GRASS-SVN] r64437 - grass/trunk/display/d.mon

svn_grass at osgeo.org svn_grass at osgeo.org
Tue Feb 3 09:55:05 PST 2015


Author: martinl
Date: 2015-02-03 09:55:05 -0800 (Tue, 03 Feb 2015)
New Revision: 64437

Modified:
   grass/trunk/display/d.mon/start.c
   grass/trunk/display/d.mon/stop.c
Log:
d.mon: fix handling wx-monitors
       message cosmetics (<>)


Modified: grass/trunk/display/d.mon/start.c
===================================================================
--- grass/trunk/display/d.mon/start.c	2015-02-03 17:54:21 UTC (rev 64436)
+++ grass/trunk/display/d.mon/start.c	2015-02-03 17:55:05 UTC (rev 64437)
@@ -33,7 +33,7 @@
             return NULL;
         if (!update && access(output_name, F_OK) == 0) {
             if (G_get_overwrite()) {
-                G_warning(_("File '%s' already exists and will be overwritten"), output_name);
+                G_warning(_("File <%s> already exists and will be overwritten"), output_name);
                 D_setup_unity(0);
                 D_erase("white");
             }
@@ -102,7 +102,7 @@
     G_spawn_ex(getenv("GRASS_PYTHON"), progname, progname,
 	       name, element, str_width, str_height, str_x_only, SF_BACKGROUND, NULL);
 
-    G_file_name(mapfile, element, "ppm", G_mapset());
+    G_file_name(mapfile, element, "map.ppm", G_mapset());
     
     return mapfile;
 }
@@ -200,9 +200,13 @@
     G_debug(1, "Monitor name=%s, envfile=%s", name, env_file);
     fd = creat(env_file, 0666);
     if (fd < 0)
-	G_fatal_error(_("Unable to create file '%s'"), env_file);
+	G_fatal_error(_("Unable to create file <%s>"), env_file);
+
+    if (G_strncasecmp(name, "wx", 2) == 0)
+        sprintf(buf, "GRASS_RENDER_IMMEDIATE=default\n"); /* TODO: read settings from wxGUI */
+    else
+        sprintf(buf, "GRASS_RENDER_IMMEDIATE=%s\n", name);
     
-    sprintf(buf, "GRASS_RENDER_IMMEDIATE=%s\n", name);
     write(fd, buf, strlen(buf));
     sprintf(buf, "GRASS_RENDER_FILE=%s\n", out_file);
     write(fd, buf, strlen(buf));
@@ -232,7 +236,7 @@
     /* create cmd file (list of GRASS display commands to render) */
     G_debug(1, "Monitor name=%s, cmdfile = %s", name, cmd_file);
     if (0 > creat(cmd_file, 0666))
-        G_fatal_error(_("Unable to create file '%s'"), cmd_file);
+        G_fatal_error(_("Unable to create file <%s>"), cmd_file);
 
     /* select monitor if requested */
     if (select)

Modified: grass/trunk/display/d.mon/stop.c
===================================================================
--- grass/trunk/display/d.mon/stop.c	2015-02-03 17:54:21 UTC (rev 64436)
+++ grass/trunk/display/d.mon/stop.c	2015-02-03 17:55:05 UTC (rev 64437)
@@ -19,7 +19,7 @@
     }
     
     if (strncmp(name, "wx", 2) == 0)
-	return stop_wx(name);
+	stop_wx(name);
 
     return stop(name);
 }
@@ -38,12 +38,12 @@
             continue;
         sprintf(file_path, "%s/%s", mon_path, dp->d_name);
         if (unlink(file_path) == -1)
-            G_warning(_("Unable to delete file '%s'"), file_path);
+            G_warning(_("Unable to delete file <%s>"), file_path);
     }
     closedir(dirp);
     
     if (rmdir(mon_path) == -1)
-        G_warning(_("Unable to delete directory '%s'"), mon_path);
+        G_warning(_("Unable to delete directory <%s>"), mon_path);
 
     G_free(mon_path);
 
@@ -54,15 +54,26 @@
 
 int stop_wx(const char *name)
 {
-    char *env_name;
-    const char *pid;
-
-    env_name = NULL;
-    G_asprintf(&env_name, "MONITOR_%s_PID", G_store_upper(name));
+    char *mon_path, *pid;
+    char pid_file[GPATH_MAX], buf[512];
+    FILE *fp;
     
-    pid = G_getenv_nofatal(env_name);
+    mon_path = get_path(name, FALSE);
+    G_file_name(pid_file, mon_path, "pid", G_mapset());
+    
+    fp = fopen(pid_file, "r");
+    if (!fp) {
+	G_warning(_("Unable to open file <%s>"), pid_file);
+        return 1;
+    }
+    pid = NULL;
+    if (G_getl2(buf, sizeof(buf) - 1, fp) != 0)
+        pid = G_store(buf);
+    fclose(fp);
+    
     if (!pid) {
-	G_fatal_error(_("PID file not found"));
+	G_warning(_("Unable to read file <%s>"), pid_file);
+        return 1;
     }
     
 #ifdef __MINGW32__



More information about the grass-commit mailing list