Skip to content
Snippets Groups Projects
Commit 0fda885c authored by Christophe Geuzaine's avatar Christophe Geuzaine
Browse files

fix problem with new dynamic menus and plugin dialogs (unfortunately, this
re-adds the (small) memory leak in the GUI)
parent 9d4f38b4
No related branches found
No related tags found
No related merge requests found
// $Id: Callbacks.cpp,v 1.274 2004-09-18 20:25:25 geuzaine Exp $
// $Id: Callbacks.cpp,v 1.275 2004-09-19 03:42:11 geuzaine Exp $
//
// Copyright (C) 1997-2004 C. Geuzaine, J.-F. Remacle
//
......@@ -3237,13 +3237,12 @@ void view_options_cb(CALLBACK_ARGS)
void view_plugin_cb(CALLBACK_ARGS)
{
char name[256];
std::pair < int, GMSH_Plugin * >*pair =
(std::pair < int, GMSH_Plugin * >*)data;
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);
if(p->dialogBox) { //Get the values from the GUI
if(p->dialogBox) { // get the values from the GUI
int m = p->getNbOptionsStr();
int n = p->getNbOptions();
if(m > 20) m = 20;
......@@ -3271,8 +3270,7 @@ void view_plugin_cb(CALLBACK_ARGS)
void view_options_plugin_cb(CALLBACK_ARGS)
{
std::pair < int, GMSH_Plugin * >*pair =
(std::pair < int, GMSH_Plugin * >*)data;
std::pair<int, GMSH_Plugin *> *pair = (std::pair<int, GMSH_Plugin *>*) data;
GMSH_Plugin *p = pair->second;
if(!p->dialogBox)
......
// $Id: GUI.cpp,v 1.348 2004-09-18 20:25:26 geuzaine Exp $
// $Id: GUI.cpp,v 1.349 2004-09-19 03:42:11 geuzaine Exp $
//
// Copyright (C) 1997-2004 C. Geuzaine, J.-F. Remacle
//
......@@ -827,11 +827,13 @@ 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);
sprintf(menuname, "Plugins/%s...", name);
button->add(menuname, 0, (Fl_Callback *) view_options_plugin_cb, (void *)(pair), 0);
m_pop_plugin.push_back(pair);
p->dialogBox = 0;
button->add(menuname, 0, (Fl_Callback *) view_options_plugin_cb, (void *)pair, 0);
}
}
}
......@@ -1007,9 +1009,6 @@ 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;
......
......@@ -143,7 +143,6 @@ 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 ;
......
......@@ -57,6 +57,8 @@ public :
GMSH_POST_PLUGIN,
GMSH_SOLVE_PLUGIN} GMSH_PLUGIN_TYPE ;
GMSH_Plugin() : dialogBox(0), hlib(0) {;};
// returns the type of plugin for downcasting GMSH_Plugin into
// GMSH_CAD_Plugin, GMSH_Mesh_Plugin and GMSH_Post_Plugin
virtual GMSH_PLUGIN_TYPE getType() const = 0;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment