From: dooglus Date: Tue, 30 Oct 2007 03:09:12 +0000 (+0000) Subject: Fix 1820750. Delete popup menus once we're finished with them, so they don't keep... X-Git-Url: https://git.pterodactylus.net/?a=commitdiff_plain;h=560dfdcfea7dbf8d80e599d1d204c253f56a505d;p=synfig.git Fix 1820750. Delete popup menus once we're finished with them, so they don't keep references to objects lying around. git-svn-id: http://svn.voria.com/code@999 1f10aa63-cdf2-0310-b900-c93c546f37ac --- diff --git a/synfig-studio/trunk/src/gtkmm/app.cpp b/synfig-studio/trunk/src/gtkmm/app.cpp index bd35bc8..7f28f01 100644 --- a/synfig-studio/trunk/src/gtkmm/app.cpp +++ b/synfig-studio/trunk/src/gtkmm/app.cpp @@ -262,6 +262,25 @@ void studio::App::set_max_recent_files(int x) { max_recent_files_=x; } static synfig::String app_base_path_; namespace studio { + +bool +really_delete_widget(Gtk::Widget *widget) +{ + synfig::info("really delete %x", (unsigned int)widget); + delete widget; + return false; +} + +// nasty workaround - when we've finished with a popup menu, we want to delete it +// attaching to the signal_hide() signal gets us here before the action on the menu has run, +// so schedule the real delete to happen in 50ms, giving the action a chance to run +void +delete_widget(Gtk::Widget *widget) +{ + synfig::info("delete %x", (unsigned int)widget); + Glib::signal_timeout().connect(sigc::bind(sigc::ptr_fun(&really_delete_widget), widget), 50); +} + }; // END of namespace studio studio::StateManager* state_manager; diff --git a/synfig-studio/trunk/src/gtkmm/app.h b/synfig-studio/trunk/src/gtkmm/app.h index 8ed0931..d862795 100644 --- a/synfig-studio/trunk/src/gtkmm/app.h +++ b/synfig-studio/trunk/src/gtkmm/app.h @@ -327,6 +327,8 @@ public: static synfig::String get_config_file(const synfig::String& file); }; // END of class App + void delete_widget(Gtk::Widget *widget); + }; // END namespace studio /* === E N D =============================================================== */ diff --git a/synfig-studio/trunk/src/gtkmm/canvasview.cpp b/synfig-studio/trunk/src/gtkmm/canvasview.cpp index 87c58a5..a9dda3d 100644 --- a/synfig-studio/trunk/src/gtkmm/canvasview.cpp +++ b/synfig-studio/trunk/src/gtkmm/canvasview.cpp @@ -2196,6 +2196,8 @@ CanvasView::on_layer_user_click(int button, Gtk::TreeRow /*row*/, LayerTree::Col parammenu.items().clear(); Gtk::Menu *newlayers(manage(new Gtk::Menu())); + // do we need this? the code is all #ifdef'ed out anyway + // newlayers->signal_hide().connect(sigc::bind(sigc::ptr_fun(&delete_widget), newlayers)); build_new_layer_menu(*newlayers); parammenu.items().push_back(Gtk::Menu_Helpers::MenuElem("New Layer",*newlayers)); @@ -2990,6 +2992,7 @@ CanvasView::on_waypoint_clicked(synfigapp::ValueDesc value_desc,synfig::Waypoint case 2: { Gtk::Menu* waypoint_menu(manage(new Gtk::Menu())); + waypoint_menu->signal_hide().connect(sigc::bind(sigc::ptr_fun(&delete_widget), waypoint_menu)); waypoint_menu->items().push_back(Gtk::Menu_Helpers::StockMenuElem(Gtk::StockID("gtk-jump-to"), sigc::bind( diff --git a/synfig-studio/trunk/src/gtkmm/cellrenderer_timetrack.cpp b/synfig-studio/trunk/src/gtkmm/cellrenderer_timetrack.cpp index 96f19b8..514f170 100644 --- a/synfig-studio/trunk/src/gtkmm/cellrenderer_timetrack.cpp +++ b/synfig-studio/trunk/src/gtkmm/cellrenderer_timetrack.cpp @@ -938,11 +938,13 @@ CellRenderer_TimeTrack::show_timepoint_menu(const etl::handle& nod n=synfig::waypoint_collect(waypoint_set,time,node); Gtk::Menu* menu(manage(new Gtk::Menu())); + menu->signal_hide().connect(sigc::bind(sigc::ptr_fun(&delete_widget), menu)); // Create the interpolation method menu if(!waypoint_set.empty()) { Gtk::Menu* interp_menu(manage(new Gtk::Menu())); + // no need to connect to signal_hide for this one - it will be deleted when its parent is deleted Waypoint::Model model; // note: each of the following 4 'if' blocks provokes these warnings: diff --git a/synfig-studio/trunk/src/gtkmm/dock_timetrack.cpp b/synfig-studio/trunk/src/gtkmm/dock_timetrack.cpp index b51fcd8..d2f0651 100644 --- a/synfig-studio/trunk/src/gtkmm/dock_timetrack.cpp +++ b/synfig-studio/trunk/src/gtkmm/dock_timetrack.cpp @@ -177,11 +177,13 @@ public: { synfigapp::ValueDesc value_desc(row[model.value_desc]); Gtk::Menu* menu(manage(new Gtk::Menu())); + menu->signal_hide().connect(sigc::bind(sigc::ptr_fun(&delete_widget), menu)); App::get_instance(param_tree_store_->canvas_interface()->get_canvas())->make_param_menu(menu,param_tree_store_->canvas_interface()->get_canvas(),value_desc,0.5f); menu->popup(event->button.button,gtk_get_current_event_time()); return true; } Gtk::Menu* menu(manage(new Gtk::Menu())); + menu->signal_hide().connect(sigc::bind(sigc::ptr_fun(&delete_widget), menu)); std::list value_desc_list; ParamDesc param_desc(row[model.param_desc]); for(;!layer_list.empty();layer_list.pop_back()) diff --git a/synfig-studio/trunk/src/gtkmm/layertree.cpp b/synfig-studio/trunk/src/gtkmm/layertree.cpp index ba63485..24245d6 100644 --- a/synfig-studio/trunk/src/gtkmm/layertree.cpp +++ b/synfig-studio/trunk/src/gtkmm/layertree.cpp @@ -871,11 +871,13 @@ LayerTree::on_param_tree_event(GdkEvent *event) { synfigapp::ValueDesc value_desc(row[param_model.value_desc]); Gtk::Menu* menu(manage(new Gtk::Menu())); + menu->signal_hide().connect(sigc::bind(sigc::ptr_fun(&delete_widget), menu)); App::get_instance(param_tree_store_->canvas_interface()->get_canvas())->make_param_menu(menu,param_tree_store_->canvas_interface()->get_canvas(),value_desc,0.5f); menu->popup(event->button.button,gtk_get_current_event_time()); return true; } Gtk::Menu* menu(manage(new Gtk::Menu())); + menu->signal_hide().connect(sigc::bind(sigc::ptr_fun(&delete_widget), menu)); std::list value_desc_list; ParamDesc param_desc(row[param_model.param_desc]); for(;!layer_list.empty();layer_list.pop_back()) diff --git a/synfig-studio/trunk/src/gtkmm/mod_palette/dock_paledit.cpp b/synfig-studio/trunk/src/gtkmm/mod_palette/dock_paledit.cpp index 1653a19..331c4b7 100644 --- a/synfig-studio/trunk/src/gtkmm/mod_palette/dock_paledit.cpp +++ b/synfig-studio/trunk/src/gtkmm/mod_palette/dock_paledit.cpp @@ -187,6 +187,7 @@ void Dock_PalEdit::show_menu(int i) { Gtk::Menu* menu(manage(new Gtk::Menu())); + menu->signal_hide().connect(sigc::bind(sigc::ptr_fun(&delete_widget), menu)); menu->items().push_back(Gtk::Menu_Helpers::StockMenuElem(Gtk::StockID("gtk-select-color"), sigc::bind( diff --git a/synfig-studio/trunk/src/gtkmm/state_normal.cpp b/synfig-studio/trunk/src/gtkmm/state_normal.cpp index f5b98d4..dc898f4 100644 --- a/synfig-studio/trunk/src/gtkmm/state_normal.cpp +++ b/synfig-studio/trunk/src/gtkmm/state_normal.cpp @@ -395,6 +395,7 @@ StateNormal_Context::event_multiple_ducks_clicked_handler(const Smach::event& /* } Gtk::Menu *menu=manage(new Gtk::Menu()); + menu->signal_hide().connect(sigc::bind(sigc::ptr_fun(&delete_widget), menu)); canvas_view->get_instance()->make_param_menu(menu,canvas_view->get_canvas(),value_desc_list); diff --git a/synfig-studio/trunk/src/gtkmm/widget_gradient.cpp b/synfig-studio/trunk/src/gtkmm/widget_gradient.cpp index 41920d9..80738cb 100644 --- a/synfig-studio/trunk/src/gtkmm/widget_gradient.cpp +++ b/synfig-studio/trunk/src/gtkmm/widget_gradient.cpp @@ -212,6 +212,7 @@ void Widget_Gradient::popup_menu(float x) { Gtk::Menu* menu(manage(new Gtk::Menu())); + menu->signal_hide().connect(sigc::bind(sigc::ptr_fun(&delete_widget), menu)); menu->items().clear();