From 80dc596f1212770a72f7bb8d9dab79bd311c6fe6 Mon Sep 17 00:00:00 2001 From: H.G. Muller Date: Wed, 13 Apr 2011 16:15:22 +0200 Subject: [PATCH] Fix crash on closing dialogs in wrong order When a menu dialog was closed when it still had an open file-browse daughter, which could be done through the system menu X on the title bar, later closing of the file browser caused a crash. This is solved by keeping track of the fact that there is such a daughter through a global flag, and ignoring the pop-down command if there is one. --- xoptions.c | 4 ++++ 1 files changed, 4 insertions(+), 0 deletions(-) diff --git a/xoptions.c b/xoptions.c index 0689355..1bccfc3 100644 --- a/xoptions.c +++ b/xoptions.c @@ -624,6 +624,7 @@ int values[MAX_OPTIONS]; ChessProgramState *currentCps; static Option *currentOption; extern Widget shells[]; +static Boolean browserUp; void CheckCallback(Widget ww, XtPointer data, XEvent *event, Boolean *b) { @@ -659,6 +660,7 @@ void SpinCallback(w, client_data, call_data) XtSetArg(args[0], XtNstring, &q); XtGetValues(currentOption[data].handle, args, 1); for(r = ""; *q; q++) if(*q == '.') r = q; else if(*q == '/') r = ""; // last dot after last slash + browserUp = True; if(XsraSelFile(shells[0], currentOption[data].name, NULL, NULL, "", "", r, currentOption[data].type == PathName ? "p" : "f", NULL, &p)) { int len = strlen(p); @@ -666,6 +668,7 @@ void SpinCallback(w, client_data, call_data) XtSetArg(args[0], XtNstring, p); XtSetValues(currentOption[data].handle, args, 1); } + browserUp = False; SetFocus(currentOption[data].handle, shells[0], (XEvent*) NULL, False); return; } else @@ -785,6 +788,7 @@ void GenericPopDown(w, event, prms, nprms) Cardinal *nprms; { int n; + if(browserUp) return; // prevent closing dialog when it has an open file-browse daughter PopDown(prms[0][0] - '0'); } -- 1.7.0.4