Browse Source

Always check for GUI events during simulation, if any graphs exist.

Previously this check was only made if an iplot window existed.
The 100W.sp example displayed frozen windows with X11-based plotting.
pre-master-46
Giles Atkinson 1 year ago
committed by Holger Vogt
parent
commit
d18479b45b
  1. 26
      src/frontend/plotting/graf.c
  2. 16
      src/frontend/plotting/graphdb.c
  3. 3
      src/frontend/plotting/graphdb.h

26
src/frontend/plotting/graf.c

@ -868,7 +868,6 @@ static int iplot(struct plot *pl, struct dbcomm *db)
bool changed = FALSE; bool changed = FALSE;
int id, yt; int id, yt;
double xlims[2], ylims[2]; double xlims[2], ylims[2];
static REQUEST reqst = { checkup_option, NULL };
int inited = 0; int inited = 0;
int n_vec_plot = 0; int n_vec_plot = 0;
@ -958,16 +957,12 @@ static int iplot(struct plot *pl, struct dbcomm *db)
inited = 1; inited = 1;
} else { } else {
/* plot the last points and resize if needed */
Input(&reqst, NULL);
/* Window was closed? */
if (!currentgraph)
if (!currentgraph) /* Window was closed? */
return 0; 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] : dy = (isreal(xs) ? xs->v_realdata[len - 1] :
realpart(xs->v_compdata[len - 1])); realpart(xs->v_compdata[len - 1]));
@ -1194,9 +1189,16 @@ void reset_trace(void)
void gr_iplot(struct plot *plot) 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; hit = 0;
for (db = dbs; db; db = db->db_next) { for (db = dbs; db; db = db->db_next) {

16
src/frontend/plotting/graphdb.c

@ -41,6 +41,10 @@ typedef struct gbucket {
static GBUCKET GBucket[NUMGBUCKETS]; 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. */ /* note: Zero is not a valid id. This is used in plot() in graf.c. */
static int RunningId = 1; static int RunningId = 1;
@ -81,7 +85,7 @@ GRAPH *NewGraph(void)
} }
RunningId++; RunningId++;
Have_graph = TRUE;
return pgraph; return pgraph;
} /* end of function NewGraph */ } /* end of function NewGraph */
@ -108,7 +112,6 @@ GRAPH *FindGraph(int id)
} /* end of function FindGraph */ } /* end of function FindGraph */
GRAPH *CopyGraph(GRAPH *graph) GRAPH *CopyGraph(GRAPH *graph)
{ {
GRAPH *ret; GRAPH *ret;
@ -235,7 +238,15 @@ int DestroyGraph(int id)
lastlist->next = list->next; lastlist->next = list->next;
} }
else { /* at front */ else { /* at front */
int i;
GBucket[index].list = list->next; 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 */ /* Run through and de-allocate dynamically allocated keyed list */
@ -307,6 +318,7 @@ void FreeGraphs(void)
txfree(deadl); txfree(deadl);
} }
} }
Have_graph = FALSE;
} /* end of functdion FreeGraphs */ } /* end of functdion FreeGraphs */

3
src/frontend/plotting/graphdb.h

@ -12,4 +12,7 @@ void SetGraphContext(int graphid);
void PushGraphContext(GRAPH *graph); void PushGraphContext(GRAPH *graph);
void PopGraphContext(void); void PopGraphContext(void);
/* Global variable to indicate that at least one graph exits. Ugly but fast. */
extern bool Have_graph;
#endif #endif
Loading…
Cancel
Save