From 2d1e44787b90f89c6efc4613708c5630e96f74eb Mon Sep 17 00:00:00 2001 From: rlar Date: Thu, 2 Jun 2011 13:28:36 +0000 Subject: [PATCH] fix a segfault, when invoking `destroy' while running in batch mode on unix --- ChangeLog | 5 +++++ src/frontend/plotting/graf.c | 12 +----------- src/frontend/plotting/x11.c | 12 ++++++++---- 3 files changed, 14 insertions(+), 15 deletions(-) diff --git a/ChangeLog b/ChangeLog index afee9a0a4..a876c54ea 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,8 @@ +2011-06-02 Robert Larice + * src/frontend/plotting/graf.c , + * src/frontend/plotting/x11.c : + fix a segfault, when invoking `destroy' while running in batch mode on unix + 2011-06-02 Robert Larice * src/frontend/evaluate.c : fix a segfault, incorrect invocation of free() diff --git a/src/frontend/plotting/graf.c b/src/frontend/plotting/graf.c index 4da043057..ee95c2cf3 100644 --- a/src/frontend/plotting/graf.c +++ b/src/frontend/plotting/graf.c @@ -132,7 +132,6 @@ gr_init(double *xlims, double *ylims, /* The size of the screen. */ graph->data.ymin = ylims[0]; graph->data.ymax = ylims[1]; /* get title into plot window */ -#ifdef HAS_WINDOWS if (!pname) pname = "(unknown)"; if (!plotname) @@ -140,7 +139,6 @@ gr_init(double *xlims, double *ylims, /* The size of the screen. */ comb_title = TMALLOC(char, strlen(plotname) + strlen(pname) + 3); sprintf(comb_title, "%s: %s", pname, plotname); graph->plotname = comb_title; -#endif /* note: have enum here or some better convention */ if (NewViewport(graph) == 1) { @@ -187,15 +185,7 @@ gr_init(double *xlims, double *ylims, /* The size of the screen. */ graph->grid.ylabel = "imag"; } } -#ifndef HAS_WINDOWS - if (!pname) - pname = "(unknown)"; - if (!plotname) - plotname = "(unknown)"; - comb_title = TMALLOC(char, strlen(plotname) + strlen(pname) + 3); - sprintf(comb_title, "%s: %s", pname, plotname); - graph->plotname = comb_title; -#endif + gr_resize_internal(graph); gr_redrawgrid(graph); diff --git a/src/frontend/plotting/x11.c b/src/frontend/plotting/x11.c index 00937acee..e5dc51182 100644 --- a/src/frontend/plotting/x11.c +++ b/src/frontend/plotting/x11.c @@ -907,12 +907,16 @@ killwin(Widget w, XtPointer client_data, XtPointer call_data) void RemoveWindow(GRAPH *graph) { - /* Iplots are done asynchronously */ - DEVDEP(graph).isopen = 0; - /* MW. Not sure but DestroyGraph might free() to much - try Xt...() first */ - XtDestroyWidget(DEVDEP(graph).shell); + if(graph->devdep) { + /* Iplots are done asynchronously */ + DEVDEP(graph).isopen = 0; + /* MW. Not sure but DestroyGraph might free() to much - try Xt...() first */ + XtDestroyWidget(DEVDEP(graph).shell); + } + if (graph == currentgraph) currentgraph = NULL; + DestroyGraph(graph->graphid); }