diff --git a/src/frontend/plotting/graf.c b/src/frontend/plotting/graf.c index 86bec65b5..8f5404936 100644 --- a/src/frontend/plotting/graf.c +++ b/src/frontend/plotting/graf.c @@ -868,7 +868,6 @@ static int iplot(struct plot *pl, struct dbcomm *db) bool changed = FALSE; int id, yt; double xlims[2], ylims[2]; - static REQUEST reqst = { checkup_option, NULL }; int inited = 0; int n_vec_plot = 0; @@ -958,16 +957,12 @@ static int iplot(struct plot *pl, struct dbcomm *db) inited = 1; } else { - /* plot the last points and resize if needed */ - - Input(&reqst, NULL); - - /* Window was closed? */ - - if (!currentgraph) + if (!currentgraph) /* Window was closed? */ return 0; - /* First see if we have to make the screen bigger */ + /* Plot the latest points and resize if needed. + * First see if we have to make the screen bigger. + */ dy = (isreal(xs) ? xs->v_realdata[len - 1] : realpart(xs->v_compdata[len - 1])); @@ -1194,9 +1189,16 @@ void reset_trace(void) void gr_iplot(struct plot *plot) { - struct dbcomm *db; - int dontpop; /* So we don't pop w/o push. */ - char buf[30]; + static REQUEST reqst = { checkup_option, NULL }; + struct dbcomm *db, *dc; + int dontpop; /* So we don't pop w/o push. */ + char buf[30]; + + if (Have_graph) { + /* There is at least one graph. Process input on graph windows. */ + + Input(&reqst, NULL); + } hit = 0; for (db = dbs; db; db = db->db_next) { diff --git a/src/frontend/plotting/graphdb.c b/src/frontend/plotting/graphdb.c index 4081e80e6..890dbc199 100644 --- a/src/frontend/plotting/graphdb.c +++ b/src/frontend/plotting/graphdb.c @@ -41,6 +41,10 @@ typedef struct gbucket { static GBUCKET GBucket[NUMGBUCKETS]; +/* Global variable to indicate that at least one graph exits. Ugly but fast. */ + +bool Have_graph; + /* note: Zero is not a valid id. This is used in plot() in graf.c. */ static int RunningId = 1; @@ -81,7 +85,7 @@ GRAPH *NewGraph(void) } RunningId++; - + Have_graph = TRUE; return pgraph; } /* end of function NewGraph */ @@ -108,7 +112,6 @@ GRAPH *FindGraph(int id) } /* end of function FindGraph */ - GRAPH *CopyGraph(GRAPH *graph) { GRAPH *ret; @@ -235,7 +238,15 @@ int DestroyGraph(int id) lastlist->next = list->next; } else { /* at front */ + int i; + GBucket[index].list = list->next; + for (i = 0; i < NUMGBUCKETS; ++i) { + if (GBucket[i].list) + break; + } + if (i >= NUMGBUCKETS) + Have_graph = FALSE; } /* Run through and de-allocate dynamically allocated keyed list */ @@ -307,6 +318,7 @@ void FreeGraphs(void) txfree(deadl); } } + Have_graph = FALSE; } /* end of functdion FreeGraphs */ diff --git a/src/frontend/plotting/graphdb.h b/src/frontend/plotting/graphdb.h index 14114488a..8f1624c51 100644 --- a/src/frontend/plotting/graphdb.h +++ b/src/frontend/plotting/graphdb.h @@ -12,4 +12,7 @@ void SetGraphContext(int graphid); void PushGraphContext(GRAPH *graph); void PopGraphContext(void); +/* Global variable to indicate that at least one graph exits. Ugly but fast. */ + +extern bool Have_graph; #endif