[Aptitude-svn-commit] r3751 - in branches/aptitude-0.3/aptitude: . src

Daniel Burrows dburrows at costa.debian.org
Mon Aug 8 19:12:45 UTC 2005


Author: dburrows
Date: Mon Aug  8 19:12:43 2005
New Revision: 3751

Modified:
   branches/aptitude-0.3/aptitude/ChangeLog
   branches/aptitude-0.3/aptitude/src/solution_dialog.cc
   branches/aptitude-0.3/aptitude/src/solution_dialog.h
Log:
Update the solution dialog for refcounting.

Modified: branches/aptitude-0.3/aptitude/ChangeLog
==============================================================================
--- branches/aptitude-0.3/aptitude/ChangeLog	(original)
+++ branches/aptitude-0.3/aptitude/ChangeLog	Mon Aug  8 19:12:43 2005
@@ -1,5 +1,9 @@
 2005-08-08  Daniel Burrows  <dburrows at debian.org>
 
+	* src/solution_dialog.cc, src/solution_dialog.h:
+
+	  Update the solution dialog for refcounting.
+
 	* src/pkg_view.cc, src/pkg_view.h:
 
 	  Update the package view generation code for refcounting.

Modified: branches/aptitude-0.3/aptitude/src/solution_dialog.cc
==============================================================================
--- branches/aptitude-0.3/aptitude/src/solution_dialog.cc	(original)
+++ branches/aptitude-0.3/aptitude/src/solution_dialog.cc	Mon Aug  8 19:12:43 2005
@@ -52,7 +52,8 @@
 
     update();
   }
-public:
+
+protected:
   solution_dialog()
   {
     if(apt_cache_file)
@@ -67,6 +68,12 @@
     update();
   }
 
+public:
+  static ref_ptr<solution_dialog> create()
+  {
+    return new solution_dialog;
+  }
+
   void update()
   {
     if(!apt_cache_file)
@@ -110,22 +117,26 @@
   }
 };
 
-static void do_apply(vscreen_widget *w)
+typedef ref_ptr<solution_dialog> solution_dialog_ref;
+
+static void do_apply(vscreen_widget &wBare)
 {
+  vs_widget_ref w(&wBare);
+
   do_apply_solution();
   w->destroy();
 }
 
-vscreen_widget *make_solution_dialog()
+vs_widget_ref make_solution_dialog()
 {
-  vs_table *t=new vs_table;
-  vscreen_widget *rval=new vs_center(new vs_frame(t));
+  vs_table_ref t=vs_table::create();
+  vs_widget_ref rval=vs_center::create(vs_frame::create(t));
 
-  vs_text_layout *display=new solution_dialog;
-  vs_scrollbar *scrl=new vs_scrollbar(vs_scrollbar::VERTICAL);
+  vs_text_layout_ref display=solution_dialog::create();
+  vs_scrollbar_ref scrl=vs_scrollbar::create(vs_scrollbar::VERTICAL);
 
-  display->location_changed.connect(sigc::mem_fun(scrl, &vs_scrollbar::set_slider));
-  scrl->scrollbar_interaction.connect(sigc::mem_fun(display, &vs_text_layout::scroll));
+  display->location_changed.connect(sigc::mem_fun(scrl.unsafe_get_ref(), &vs_scrollbar::set_slider));
+  scrl->scrollbar_interaction.connect(sigc::mem_fun(display.unsafe_get_ref(), &vs_text_layout::scroll));
 
   t->add_widget_opts(display,
 		     0, 0, 1, 1,
@@ -137,27 +148,27 @@
 		     vs_table::ALIGN_RIGHT,
 		     vs_table::ALIGN_CENTER | vs_table::FILL | vs_table::SHRINK);
 
-  vs_table *bt=new vs_table;
+  vs_table_ref bt=vs_table::create();
 
   //t->set_bg(get_color("DefaultWidgetBackground")|A_REVERSE);
 
   // TODO: for dialogs like this, I really should have support for
   // "wrapping" lines of buttons if they get too long, like fragments.
-  vs_button *bprev=new vs_button(_("Previous"));
-  vs_button *bnext=new vs_button(_("Next"));
-  vs_button *bapply=new vs_button(_("Apply"));
-  vs_button *bclose=new vs_button(_("Close"));
+  vs_button_ref bprev  = vs_button::create(_("Previous"));
+  vs_button_ref bnext  = vs_button::create(_("Next"));
+  vs_button_ref bapply = vs_button::create(_("Apply"));
+  vs_button_ref bclose = vs_button::create(_("Close"));
 
   bprev->pressed.connect(sigc::ptr_fun(do_previous_solution));
   bnext->pressed.connect(sigc::ptr_fun(do_next_solution));
   bapply->pressed.connect(sigc::bind(sigc::ptr_fun(do_apply),
-				     rval));
-  bclose->pressed.connect(sigc::mem_fun(rval,
+				     rval.weak_ref()));
+  bclose->pressed.connect(sigc::mem_fun(rval.unsafe_get_ref(),
 					&vscreen_widget::destroy));
 
   rval->connect_key("ApplySolution", &global_bindings,
 		    sigc::bind(sigc::ptr_fun(do_apply),
-			       rval));
+			       rval.weak_ref()));
 
   bprev->set_bg_style(style_attrs_flip(A_REVERSE));
   bnext->set_bg_style(style_attrs_flip(A_REVERSE));

Modified: branches/aptitude-0.3/aptitude/src/solution_dialog.h
==============================================================================
--- branches/aptitude-0.3/aptitude/src/solution_dialog.h	(original)
+++ branches/aptitude-0.3/aptitude/src/solution_dialog.h	Mon Aug  8 19:12:43 2005
@@ -23,7 +23,9 @@
 #define SOLUTION_DIALOG_H
 
 class vscreen_widget;
+template<class T> class ref_ptr;
+typedef ref_ptr<vscreen_widget> vs_widget_ref;
 
-vscreen_widget *make_solution_dialog();
+vs_widget_ref make_solution_dialog();
 
 #endif // SOLUTION_DIALOG_H



More information about the Aptitude-svn-commit mailing list