On Wed, Oct 05, 2005 at 02:00:40AM +0200, Frank Lichtenheld wrote: > I notice an interesting problem with the search box in the > experimental version: > > If I type a search term and go to the "Ok" button and hit "enter", the > search term seems not to be saved. If I hit "n" nothing happens or > the last saved search term is used, depending on what I did before the > search. > If I don't go to "Ok", but hit "enter" with the cursor still in the > input field everything works as expected...
Should be fixed with the attached patch. Daniel
Tue Oct 4 17:56:04 PDT 2005 Daniel Burrows <[EMAIL PROTECTED]> * Explicitly hold references to a string dialog while executing its OK handler. This avoids a situation where signals were disconnected too soon due to the dialog dying after it was destroyed. (Closes: #332179) Tue Oct 4 17:35:29 PDT 2005 Daniel Burrows <[EMAIL PROTECTED]> * Eliminate an unnecessary auxillary function using sigc::hide. diff -rN -u old-aptitude/src/vscreen/vs_util.cc new-aptitude/src/vscreen/vs_util.cc --- old-aptitude/src/vscreen/vs_util.cc 2005-10-04 17:57:53.000000000 -0700 +++ new-aptitude/src/vscreen/vs_util.cc 2005-10-04 17:55:43.000000000 -0700 @@ -16,6 +16,7 @@ #include <config/keybindings.h> #include <sigc++/adaptors/bind.h> +#include <sigc++/adaptors/hide.h> #include <sigc++/functors/mem_fun.h> #include <aptitude.h> @@ -286,17 +287,18 @@ encoding); } -static void do_dialog_string(wstring s, - sigc::slot0<void> realslot) -{ - realslot(); -} - -static void also_do_dialog_string(vs_editline &e, - sigc::slot1<void, wstring> thestrslot) -{ - e.add_to_history(e.get_text()); - thestrslot(e.get_text()); +static void do_dialog_string(vs_editline &eBare, + vscreen_widget &dialogBare, + slotarg<sigc::slot1<void, wstring> > thestrslot) +{ + vs_editline_ref e(&eBare); + vs_widget_ref dialog(&dialogBare); + + dialog->destroy(); + + e->add_to_history(e->get_text()); + if(thestrslot) + (*thestrslot)(e->get_text()); } vs_widget_ref vs_dialog_string(const vs_widget_ref &msg, @@ -325,18 +327,15 @@ vs_table::ALIGN_CENTER|vs_table::SHRINK, vs_table::ALIGN_CENTER); - e->entered.connect(sigc::bind(sigc::ptr_fun(do_dialog_string), - bok->pressed.make_slot())); + e->entered.connect(sigc::hide(bok->pressed.make_slot())); if(changed_slot) e->text_changed.connect(*changed_slot); t->connect_key_post("Cancel", &global_bindings, bcancel->pressed.make_slot()); - bok->pressed.connect(sigc::mem_fun(*c.unsafe_get_ref(), &vscreen_widget::destroy)); - if(slot) - bok->pressed.connect(sigc::bind(sigc::ptr_fun(also_do_dialog_string), - e.weak_ref(), *slot)); + bok->pressed.connect(sigc::bind(sigc::ptr_fun(do_dialog_string), + e.weak_ref(), c.weak_ref(), slot)); bcancel->pressed.connect(sigc::mem_fun(*c.unsafe_get_ref(), &vscreen_widget::destroy)); if(cancel_slot)