Fix 1820750. Delete popup menus once we're finished with them, so they don't keep...
authordooglus <dooglus@1f10aa63-cdf2-0310-b900-c93c546f37ac>
Tue, 30 Oct 2007 03:09:12 +0000 (03:09 +0000)
committerdooglus <dooglus@1f10aa63-cdf2-0310-b900-c93c546f37ac>
Tue, 30 Oct 2007 03:09:12 +0000 (03:09 +0000)
git-svn-id: http://svn.voria.com/code@999 1f10aa63-cdf2-0310-b900-c93c546f37ac

synfig-studio/trunk/src/gtkmm/app.cpp
synfig-studio/trunk/src/gtkmm/app.h
synfig-studio/trunk/src/gtkmm/canvasview.cpp
synfig-studio/trunk/src/gtkmm/cellrenderer_timetrack.cpp
synfig-studio/trunk/src/gtkmm/dock_timetrack.cpp
synfig-studio/trunk/src/gtkmm/layertree.cpp
synfig-studio/trunk/src/gtkmm/mod_palette/dock_paledit.cpp
synfig-studio/trunk/src/gtkmm/state_normal.cpp
synfig-studio/trunk/src/gtkmm/widget_gradient.cpp

index bd35bc8..7f28f01 100644 (file)
@@ -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;
 
index 8ed0931..d862795 100644 (file)
@@ -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 =============================================================== */
index 87c58a5..a9dda3d 100644 (file)
@@ -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(
index 96f19b8..514f170 100644 (file)
@@ -938,11 +938,13 @@ CellRenderer_TimeTrack::show_timepoint_menu(const etl::handle<synfig::Node>& 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:
index b51fcd8..d2f0651 100644 (file)
@@ -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<synfigapp::ValueDesc> value_desc_list;
                                                ParamDesc param_desc(row[model.param_desc]);
                                                for(;!layer_list.empty();layer_list.pop_back())
index ba63485..24245d6 100644 (file)
@@ -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<synfigapp::ValueDesc> value_desc_list;
                                        ParamDesc param_desc(row[param_model.param_desc]);
                                        for(;!layer_list.empty();layer_list.pop_back())
index 1653a19..331c4b7 100644 (file)
@@ -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(
index f5b98d4..dc898f4 100644 (file)
@@ -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);
 
index 41920d9..80738cb 100644 (file)
@@ -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();