From 277aedb980e390eb65d7731b759f22691f3055a1 Mon Sep 17 00:00:00 2001
From: Christophe Geuzaine <cgeuzaine@ulg.ac.be>
Date: Tue, 9 Nov 2004 02:14:19 +0000
Subject: [PATCH] - avoid querying menu/browser->value() when it doesn't make
 sense - fixed out-of-sync option panel when removing views

---
 Common/Options.cpp |  4 +++-
 Fltk/GUI.cpp       | 20 ++++++++++++--------
 2 files changed, 15 insertions(+), 9 deletions(-)

diff --git a/Common/Options.cpp b/Common/Options.cpp
index 7a7aaad23f..d29a0aff50 100644
--- a/Common/Options.cpp
+++ b/Common/Options.cpp
@@ -1,4 +1,4 @@
-// $Id: Options.cpp,v 1.201 2004-11-08 23:28:47 geuzaine Exp $
+// $Id: Options.cpp,v 1.202 2004-11-09 02:14:19 geuzaine Exp $
 //
 // Copyright (C) 1997-2004 C. Geuzaine, J.-F. Remacle
 //
@@ -5306,6 +5306,8 @@ double opt_view_external_view(OPT_ARGS_NUM)
     int item = v->ExternalViewIndex + 1;
     if(item > -1 && item < WID->view_choice[10]->size()-1)
       WID->view_choice[10]->value(item);
+    else
+      WID->view_choice[10]->value(0);
   }
 #endif
   return v->ExternalViewIndex;
diff --git a/Fltk/GUI.cpp b/Fltk/GUI.cpp
index 1f500f3a96..b1644d6840 100644
--- a/Fltk/GUI.cpp
+++ b/Fltk/GUI.cpp
@@ -1,4 +1,4 @@
-// $Id: GUI.cpp,v 1.375 2004-11-08 23:28:47 geuzaine Exp $
+// $Id: GUI.cpp,v 1.376 2004-11-09 02:14:19 geuzaine Exp $
 //
 // Copyright (C) 1997-2004 C. Geuzaine, J.-F. Remacle
 //
@@ -1441,23 +1441,23 @@ void GUI::reset_option_browser()
     sprintf(str, "View [%d]", i);
     opt_browser->add(str);
   }
-  if(select <= opt_browser->size())
-    opt_browser->value(select);
+  int item = (select <= opt_browser->size()) ? select : opt_browser->size();
+  opt_browser->value(item);
+  if(opt_window->shown())
+    options_browser_cb(NULL, NULL);
 }
 
 void GUI::reset_external_view_list()
 {
   char str[32];
-  int select = view_choice[10]->value();
   view_choice[10]->clear();
   view_choice[10]->add("Self");
   for(int i = 0; i < List_Nbr(CTX.post.list); i++) {
     sprintf(str, "View [%d]", i);
     view_choice[10]->add(str, 0, NULL);
   }
-  // warning: Fl_Choice::size() returns number of items+1
-  if(select < view_choice[10]->size() - 1)
-    view_choice[10]->value(select);
+  if(view_number >= 0)
+    opt_view_external_view(view_number, GMSH_GUI, 0);
 }
 
 void GUI::check_rotation_center_button()
@@ -1509,7 +1509,11 @@ void GUI::create_option_window()
 
   opt_browser = new Fl_Hold_Browser(WB, WB, L - WB, height - 3 * WB - BH);
   opt_browser->has_scrollbar(Fl_Browser_::VERTICAL);
-  reset_option_browser();
+  opt_browser->add("General");
+  opt_browser->add("Geometry");
+  opt_browser->add("Mesh");
+  opt_browser->add("Solver");
+  opt_browser->add("Post-processing");
   opt_browser->callback(options_browser_cb);
   opt_browser->value(1);
   opt_window->label("Options - General");
-- 
GitLab