From ae1543ebf2d0a831ecdea38daf9e6a66fc814b47 Mon Sep 17 00:00:00 2001
From: Christophe Geuzaine <cgeuzaine@ulg.ac.be>
Date: Sat, 31 Jan 2009 00:43:28 +0000
Subject: [PATCH] trying to fix weird race condition on windows causing the
 solver window to close when closing the message window

---
 Fltk/solverWindow.cpp | 7 +++++--
 1 file changed, 5 insertions(+), 2 deletions(-)

diff --git a/Fltk/solverWindow.cpp b/Fltk/solverWindow.cpp
index e1174cb381..04e260dd72 100644
--- a/Fltk/solverWindow.cpp
+++ b/Fltk/solverWindow.cpp
@@ -32,7 +32,6 @@ void solver_cb(Fl_Widget *w, void *data)
       first[i] = 1;
     init = 1;
   }
-
   if(first[num]) {
     first[num] = 0;
     char file[256], no_ext[256], ext[256], base[256];
@@ -41,6 +40,11 @@ void solver_cb(Fl_Widget *w, void *data)
     strcat(file, SINFO[num].extension.c_str());
     GUI::instance()->solver[num]->input[0]->value(file);
   }
+  // show the window before calling Solver() to avoid race condition on
+  // Windows (if the message window pops up die to an error, the window
+  // callbacks get messed up)
+  GUI::instance()->solver[num]->win->show();
+
   if(SINFO[num].nboptions) {
     std::string file = FixWindowsPath
       (GUI::instance()->solver[num]->input[0]->value());
@@ -50,7 +54,6 @@ void solver_cb(Fl_Widget *w, void *data)
     sprintf(tmp, "%s %s", SINFO[num].option_command.c_str(), tmp2);
     Solver(num, tmp);
   }
-  GUI::instance()->solver[num]->win->show();
 }
 
 static void solver_file_open_cb(Fl_Widget *w, void *data)
-- 
GitLab