diff --git a/Fltk/Callbacks.cpp b/Fltk/Callbacks.cpp
index 4016bfa226d3e12097d9feb7c7ee0d3ad1e716e9..11ee21ab1095dac232e7241ee2645f473207f764 100644
--- a/Fltk/Callbacks.cpp
+++ b/Fltk/Callbacks.cpp
@@ -1,4 +1,4 @@
-// $Id: Callbacks.cpp,v 1.276 2004-09-19 06:42:38 geuzaine Exp $
+// $Id: Callbacks.cpp,v 1.277 2004-09-19 16:44:57 geuzaine Exp $
 //
 // Copyright (C) 1997-2004 C. Geuzaine, J.-F. Remacle
 //
@@ -3241,15 +3241,15 @@ void view_options_cb(CALLBACK_ARGS)
   WID->create_view_options_window((long int)data);
 }
 
-void view_plugin_cb(CALLBACK_ARGS)
+void view_plugin_run_cb(CALLBACK_ARGS)
 {
+  GMSH_Post_Plugin *p = (GMSH_Post_Plugin *) data;
   char name[256];
-  std::pair<int, GMSH_Plugin *> *pair = (std::pair<int, GMSH_Plugin *>*) data;
-  int iView = pair->first;
-  GMSH_Post_Plugin *p = (GMSH_Post_Plugin *) pair->second;
   p->getName(name);
+  int iView;
 
   if(p->dialogBox) { // get the values from the GUI
+    iView = p->dialogBox->current_view_index;
     int m = p->getNbOptionsStr();
     int n = p->getNbOptions();
     if(m > 20) m = 20;
@@ -3263,6 +3263,8 @@ void view_plugin_cb(CALLBACK_ARGS)
       sxn->def = p->dialogBox->value[i]->value();
     }
   }
+  else
+    iView = 0;
 
   try {
     Post_View *v = (Post_View *) List_Pointer_Test(CTX.post.list, iView);
@@ -3275,15 +3277,17 @@ void view_plugin_cb(CALLBACK_ARGS)
   }
 }
 
-void view_options_plugin_cb(CALLBACK_ARGS)
+void view_plugin_options_cb(CALLBACK_ARGS)
 {
   std::pair<int, GMSH_Plugin *> *pair = (std::pair<int, GMSH_Plugin *>*) data;
+  int iView = pair->first;
   GMSH_Plugin *p = pair->second;
 
   if(!p->dialogBox)
     p->dialogBox = WID->create_plugin_window(p);
 
-  p->dialogBox->run_button->callback(view_plugin_cb, (void *)pair);
+  p->dialogBox->current_view_index = iView;
+  p->dialogBox->run_button->callback(view_plugin_run_cb, (void *)p);
   p->dialogBox->main_window->show();
 }
 
diff --git a/Fltk/Callbacks.h b/Fltk/Callbacks.h
index ca7a20faa90ca6c28a37a8c056349e4a1119a116..ab6290b1327d41262b0ae556fdbb40867fa86680 100644
--- a/Fltk/Callbacks.h
+++ b/Fltk/Callbacks.h
@@ -120,9 +120,8 @@ void view_combine_time_visible_cb(CALLBACK_ARGS) ;
 void view_combine_time_by_name_cb(CALLBACK_ARGS) ;
 void view_all_visible_cb(CALLBACK_ARGS) ;
 void view_applybgmesh_cb(CALLBACK_ARGS) ;
+void view_plugin_options_cb(CALLBACK_ARGS) ;
 void view_options_cb(CALLBACK_ARGS) ;
-void view_plugin_cb(CALLBACK_ARGS) ;
-void view_options_plugin_cb(CALLBACK_ARGS) ;
 void view_options_custom_cb(CALLBACK_ARGS) ;
 void view_options_timestep_cb(CALLBACK_ARGS) ;
 void view_options_timestep_decr_cb(CALLBACK_ARGS);
diff --git a/Fltk/GUI.cpp b/Fltk/GUI.cpp
index 5eb55418eeae242904b529357f425b453d43fe2d..2994bc111e1703182c3d0f389c9870f008e71ed7 100644
--- a/Fltk/GUI.cpp
+++ b/Fltk/GUI.cpp
@@ -1,4 +1,4 @@
-// $Id: GUI.cpp,v 1.350 2004-09-19 06:42:38 geuzaine Exp $
+// $Id: GUI.cpp,v 1.351 2004-09-19 16:44:57 geuzaine Exp $
 //
 // Copyright (C) 1997-2004 C. Geuzaine, J.-F. Remacle
 //
@@ -827,13 +827,10 @@ void GUI::add_post_plugins(Fl_Menu_Button * button, int iView)
     GMSH_Plugin *p = (*it).second;
     if(p->getType() == GMSH_Plugin::GMSH_POST_PLUGIN) {
       p->getName(name);
-      // FIXME: memory leak (hard to plug, since a plugin option
-      // window can stay alive longer than the plugin menu. We should
-      // change the way the plugin info is passed to the callbacks; or
-      // store the pair info in a persistent way and reuse it.)
       std::pair<int, GMSH_Plugin*> *pair = new std::pair<int, GMSH_Plugin *>(iView, p);
+      m_pop_plugin.push_back(pair); // keep track of this, so we can free it later
       sprintf(menuname, "Plugins/%s...", name);
-      button->add(menuname, 0, (Fl_Callback *) view_options_plugin_cb, (void *)pair, 0);
+      button->add(menuname, 0, (Fl_Callback *) view_plugin_options_cb, (void *)pair, 0);
     }
   }
 }
@@ -1009,6 +1006,9 @@ void GUI::set_context(Context_Item * menu_asked, int flag)
   for(unsigned int i = 0; i < m_pop_label.size(); i++)
     delete [] m_pop_label[i];
   m_pop_label.clear();
+  for(unsigned int i = 0; i < m_pop_plugin.size(); i++) 	 
+    delete m_pop_plugin[i]; 	 
+   m_pop_plugin.clear();
 
   int width = m_window->w();
   int popw = 4 * fontsize + 3;
@@ -3015,6 +3015,7 @@ PluginDialogBox *GUI::create_plugin_window(GMSH_Plugin * p)
   int height = ((n+m > 8 ? n+m : 8) + 2) * BH + 5 * WB;
 
   PluginDialogBox *pdb = new PluginDialogBox;
+  pdb->current_view_index = 0;
   pdb->main_window = new Fl_Window(width, height);
   pdb->main_window->box(WINDOW_BOX);
   sprintf(buffer, "%s Plugin", namep);
diff --git a/Fltk/GUI.h b/Fltk/GUI.h
index 41337fcb10fa1b95a7ffcb2c7094ace1e73e6ae0..327e0f5df1efe753fa481955a21bc11868933097 100644
--- a/Fltk/GUI.h
+++ b/Fltk/GUI.h
@@ -96,6 +96,7 @@ class GMSH_Plugin;
 
 struct PluginDialogBox
 {
+  int current_view_index;
   Fl_Window *main_window;
   Fl_Return_Button *run_button;
   Fl_Value_Input *value[20];
@@ -143,6 +144,7 @@ public:
   std::vector<Fl_Menu_Button*>  m_popup_butt ;
   std::vector<Fl_Menu_Button*>  m_popup2_butt ;
   std::vector<char*>            m_pop_label ;
+  std::vector<std::pair<int, GMSH_Plugin*>*> m_pop_plugin;
 
   // graphic window
   Fl_Window        *g_window ;