[Aptitude-svn-commit] r4149 - in branches/aptitude-0.3/aptitude: . src src/mine src/vscreen

Daniel Burrows dburrows at costa.debian.org
Wed Sep 21 18:12:29 UTC 2005


Author: dburrows
Date: Wed Sep 21 18:12:25 2005
New Revision: 4149

Modified:
   branches/aptitude-0.3/aptitude/ChangeLog
   branches/aptitude-0.3/aptitude/src/broken_indicator.cc
   branches/aptitude-0.3/aptitude/src/dep_item.h
   branches/aptitude-0.3/aptitude/src/download_bar.h
   branches/aptitude-0.3/aptitude/src/download_list.h
   branches/aptitude-0.3/aptitude/src/edit_pkg_hier.h
   branches/aptitude-0.3/aptitude/src/mine/cmine.h
   branches/aptitude-0.3/aptitude/src/pkg_info_screen.h
   branches/aptitude-0.3/aptitude/src/pkg_tree.h
   branches/aptitude-0.3/aptitude/src/pkg_ver_item.h
   branches/aptitude-0.3/aptitude/src/pkg_view.cc
   branches/aptitude-0.3/aptitude/src/solution_dialog.cc
   branches/aptitude-0.3/aptitude/src/solution_screen.cc
   branches/aptitude-0.3/aptitude/src/ui.cc
   branches/aptitude-0.3/aptitude/src/view_changelog.cc
   branches/aptitude-0.3/aptitude/src/vscreen/vs_button.h
   branches/aptitude-0.3/aptitude/src/vscreen/vs_center.h
   branches/aptitude-0.3/aptitude/src/vscreen/vs_editline.h
   branches/aptitude-0.3/aptitude/src/vscreen/vs_frame.h
   branches/aptitude-0.3/aptitude/src/vscreen/vs_label.cc
   branches/aptitude-0.3/aptitude/src/vscreen/vs_label.h
   branches/aptitude-0.3/aptitude/src/vscreen/vs_menu.h
   branches/aptitude-0.3/aptitude/src/vscreen/vs_menubar.h
   branches/aptitude-0.3/aptitude/src/vscreen/vs_minibuf_win.h
   branches/aptitude-0.3/aptitude/src/vscreen/vs_multiplex.h
   branches/aptitude-0.3/aptitude/src/vscreen/vs_pager.h
   branches/aptitude-0.3/aptitude/src/vscreen/vs_scrollbar.h
   branches/aptitude-0.3/aptitude/src/vscreen/vs_size_box.h
   branches/aptitude-0.3/aptitude/src/vscreen/vs_stacked.h
   branches/aptitude-0.3/aptitude/src/vscreen/vs_statuschoice.h
   branches/aptitude-0.3/aptitude/src/vscreen/vs_table.h
   branches/aptitude-0.3/aptitude/src/vscreen/vs_text_layout.h
   branches/aptitude-0.3/aptitude/src/vscreen/vs_togglebutton.h
   branches/aptitude-0.3/aptitude/src/vscreen/vs_transient.h
   branches/aptitude-0.3/aptitude/src/vscreen/vs_tree.h
   branches/aptitude-0.3/aptitude/src/vscreen/vscreen_widget.h
Log:
Make vscreen_widget reference counts start at 1 and handle this change in *::create.

Modified: branches/aptitude-0.3/aptitude/ChangeLog
==============================================================================
--- branches/aptitude-0.3/aptitude/ChangeLog	(original)
+++ branches/aptitude-0.3/aptitude/ChangeLog	Wed Sep 21 18:12:25 2005
@@ -1,5 +1,17 @@
 2005-09-21  Daniel Burrows  <dburrows at debian.org>
 
+	* src/broken_indicator.cc, src/dep_item.h, src/download_bar.h, src/download_list.h, src/edit_pkg_hier.h, src/mine/cmine.h, src/pkg_info_screen.h, src/pkg_tree.h, src/pkg_ver_item.h, src/pkg_view.cc, src/solution_dialog.cc, src/solution_screen.cc, src/ui.cc, src/view_changelog.cc, src/vscreen/vs_button.h, src/vscreen/vs_center.h, src/vscreen/vscreen_widget.h, src/vscreen/vs_editline.h, src/vscreen/vs_frame.h, src/vscreen/vs_label.cc, src/vscreen/vs_label.h, src/vscreen/vs_menubar.h, src/vscreen/vs_menu.h, src/vscreen/vs_minibuf_win.h, src/vscreen/vs_multiplex.h, src/vscreen/vs_pager.h, src/vscreen/vs_scrollbar.h, src/vscreen/vs_size_box.h, src/vscreen/vs_stacked.h, src/vscreen/vs_statuschoice.h, src/vscreen/vs_table.h, src/vscreen/vs_text_layout.h, src/vscreen/vs_togglebutton.h, src/vscreen/vs_transient.h, src/vscreen/vs_tree.h:
+
+	  Make the reference count of vscreen_widgets default to 1, not 0.
+	  As a result, it is necessary for every creation routine to
+	  explicitly decref() its return value before returning it.  Also
+	  wrote a ::create() routine for cmine (it was missing one) and
+	  changed ui.cc to call it.
+
+	  The reason for doing this is that it allows routines run from
+	  the constructor to acquire and release references without
+	  causing the world to explode violently.
+
 	* src/apt_info_tree.cc, src/broken_indicator.cc, src/download_bar.cc, src/download_list.cc, src/download_screen.cc, src/edit_pkg_hier.cc, src/mine/cmine.cc, src/pkg_info_screen.cc, src/pkg_view.cc, src/solution_dialog.cc, src/solution_screen.cc, src/vscreen/vs_bin.cc, src/vscreen/vs_button.cc, src/vscreen/vs_center.cc, src/vscreen/vs_container.cc, src/vscreen/vscreen_widget.cc, src/vscreen/vs_editline.cc, src/vscreen/vs_frame.cc, src/vscreen/vs_label.cc, src/vscreen/vs_menubar.cc, src/vscreen/vs_menu.cc, src/vscreen/vs_minibuf_win.cc, src/vscreen/vs_multiplex.cc, src/vscreen/vs_pager.cc, src/vscreen/vs_passthrough.cc, src/vscreen/vs_scrollbar.cc, src/vscreen/vs_size_box.cc, src/vscreen/vs_stacked.cc, src/vscreen/vs_statuschoice.cc, src/vscreen/vs_table.cc:
 
 	  Take a self-reference in any routine that's not totally trivial

Modified: branches/aptitude-0.3/aptitude/src/broken_indicator.cc
==============================================================================
--- branches/aptitude-0.3/aptitude/src/broken_indicator.cc	(original)
+++ branches/aptitude-0.3/aptitude/src/broken_indicator.cc	Wed Sep 21 18:12:25 2005
@@ -179,7 +179,9 @@
 public:
   static ref_ptr<broken_indicator> create()
   {
-    return new broken_indicator;
+    ref_ptr<broken_indicator> rval(new broken_indicator);
+    rval->decref();
+    return rval;
   }
 
   // TODO: split this monster up.

Modified: branches/aptitude-0.3/aptitude/src/dep_item.h
==============================================================================
--- branches/aptitude-0.3/aptitude/src/dep_item.h	(original)
+++ branches/aptitude-0.3/aptitude/src/dep_item.h	Wed Sep 21 18:12:25 2005
@@ -66,7 +66,9 @@
 	 const pkgCache::VerIterator &ver,
 	 bool reverse = false)
   {
-    return new pkg_dep_screen(pkg, ver, reverse);
+    ref_ptr<pkg_dep_screen> rval(new pkg_dep_screen(pkg, ver, reverse));
+    rval->decref();
+    return rval;
   }
 
   virtual ~pkg_dep_screen() {}

Modified: branches/aptitude-0.3/aptitude/src/download_bar.h
==============================================================================
--- branches/aptitude-0.3/aptitude/src/download_bar.h	(original)
+++ branches/aptitude-0.3/aptitude/src/download_bar.h	Wed Sep 21 18:12:25 2005
@@ -49,7 +49,9 @@
 public:
   static ref_ptr<download_status_bar> create()
   {
-    return new download_status_bar;
+    ref_ptr<download_status_bar> rval(new download_status_bar);
+    rval->decref();
+    return rval;
   }
 
   bool MediaChange(std::string Media, std::string Drive);

Modified: branches/aptitude-0.3/aptitude/src/download_list.h
==============================================================================
--- branches/aptitude-0.3/aptitude/src/download_list.h	(original)
+++ branches/aptitude-0.3/aptitude/src/download_list.h	Wed Sep 21 18:12:25 2005
@@ -104,7 +104,9 @@
 				       bool display_messages = true,
 				       bool display_cumulative_progress = true)
   {
-    return new download_list(abortslot, display_messages, display_cumulative_progress);
+    ref_ptr<download_list> rval(new download_list(abortslot, display_messages, display_cumulative_progress));
+    rval->decref();
+    return rval;
   }
 
   void MediaChange(std::string media, std::string drive,

Modified: branches/aptitude-0.3/aptitude/src/edit_pkg_hier.h
==============================================================================
--- branches/aptitude-0.3/aptitude/src/edit_pkg_hier.h	(original)
+++ branches/aptitude-0.3/aptitude/src/edit_pkg_hier.h	Wed Sep 21 18:12:25 2005
@@ -61,7 +61,9 @@
 public:
   static ref_ptr<vs_hier_editor> create()
   {
-    return new vs_hier_editor;
+    ref_ptr<vs_hier_editor> rval(new vs_hier_editor);
+    rval->decref();
+    return rval;
   }
 
   bool get_cursorvisible();

Modified: branches/aptitude-0.3/aptitude/src/mine/cmine.h
==============================================================================
--- branches/aptitude-0.3/aptitude/src/mine/cmine.h	(original)
+++ branches/aptitude-0.3/aptitude/src/mine/cmine.h	Wed Sep 21 18:12:25 2005
@@ -71,8 +71,16 @@
 			    vs_editline &minesedit);
 protected:
   void paint_header(const style &st);
-public:
+
   cmine();
+public:
+  static ref_ptr<cmine> create()
+  {
+    ref_ptr<cmine> rval(new cmine);
+    rval->decref();
+    return rval;
+  }
+
   bool handle_key(const key &k);
   void paint(const style &st);
   ~cmine()

Modified: branches/aptitude-0.3/aptitude/src/pkg_info_screen.h
==============================================================================
--- branches/aptitude-0.3/aptitude/src/pkg_info_screen.h	(original)
+++ branches/aptitude-0.3/aptitude/src/pkg_info_screen.h	Wed Sep 21 18:12:25 2005
@@ -48,7 +48,9 @@
   create(const pkgCache::PkgIterator &pkg,
 	 const pkgCache::VerIterator &ver)
   {
-    return new pkg_info_screen(pkg, ver);
+    ref_ptr<pkg_info_screen> rval(new pkg_info_screen(pkg, ver));
+    rval->decref();
+    return rval;
   }
 };
 

Modified: branches/aptitude-0.3/aptitude/src/pkg_tree.h
==============================================================================
--- branches/aptitude-0.3/aptitude/src/pkg_tree.h	(original)
+++ branches/aptitude-0.3/aptitude/src/pkg_tree.h	Wed Sep 21 18:12:25 2005
@@ -85,7 +85,9 @@
 public:
   ref_ptr<pkg_menu_tree> create()
   {
-    return new pkg_menu_tree;
+    ref_ptr<pkg_menu_tree> rval(new pkg_menu_tree);
+    rval->decref();
+    return rval;
   }
 
   ~pkg_menu_tree();
@@ -219,7 +221,9 @@
 	 pkg_grouppolicy_factory *grouping,
 	 const std::wstring &limitstr)
   {
-    return new pkg_tree(groupingstr, grouping, limitstr);
+    ref_ptr<pkg_tree> rval(new pkg_tree(groupingstr, grouping, limitstr));
+    rval->decref();
+    return rval;
   }
 
   /** Initialize a package tree, but don't build it.  The caller
@@ -232,7 +236,9 @@
   create(const std::string &groupingstr,
 	 pkg_grouppolicy_factory *grouping)
   {
-    return new pkg_tree(groupingstr, grouping);
+    ref_ptr<pkg_tree> rval(new pkg_tree(groupingstr, grouping));
+    rval->decref();
+    return rval;
   }
 
   // Should you be able to just pass in a string (?)

Modified: branches/aptitude-0.3/aptitude/src/pkg_ver_item.h
==============================================================================
--- branches/aptitude-0.3/aptitude/src/pkg_ver_item.h	(original)
+++ branches/aptitude-0.3/aptitude/src/pkg_ver_item.h	Wed Sep 21 18:12:25 2005
@@ -138,7 +138,9 @@
 public:
   static ref_ptr<pkg_ver_screen> create(const pkgCache::PkgIterator &pkg)
   {
-    return new pkg_ver_screen(pkg);
+    ref_ptr<pkg_ver_screen> rval(new pkg_ver_screen(pkg));
+    rval->decref();
+    return rval;
   }
 };
 

Modified: branches/aptitude-0.3/aptitude/src/pkg_view.cc
==============================================================================
--- branches/aptitude-0.3/aptitude/src/pkg_view.cc	(original)
+++ branches/aptitude-0.3/aptitude/src/pkg_view.cc	Wed Sep 21 18:12:25 2005
@@ -79,7 +79,9 @@
   static ref_ptr<pkg_handling_label>
   create(column_definition_list *columns)
   {
-    return new pkg_handling_label(columns);
+    ref_ptr<pkg_handling_label> rval(new pkg_handling_label(columns));
+    rval->decref();
+    return rval;
   }
 
   ~pkg_handling_label() {delete columns;}
@@ -166,7 +168,9 @@
 public:
   static ref_ptr<pkg_description_widget> create()
   {
-    return new pkg_description_widget;
+    ref_ptr<pkg_description_widget> rval(new pkg_description_widget);
+    rval->decref();
+    return rval;
   }
 
   void set_package(const pkgCache::PkgIterator &pkg,
@@ -260,8 +264,11 @@
 	 const vs_text_layout_ref &reasons,
 	 const vs_table_ref &reasons_table)
   {
-    return new info_area_multiplex(editor, description, description_table,
-				   reasons, reasons_table);
+    ref_ptr<info_area_multiplex>
+      rval(new info_area_multiplex(editor, description, description_table,
+				   reasons, reasons_table));
+    rval->decref();
+    return rval;
   }
 
   void line_up()

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	Wed Sep 21 18:12:25 2005
@@ -92,7 +92,9 @@
 public:
   static ref_ptr<solution_dialog> create()
   {
-    return new solution_dialog;
+    ref_ptr<solution_dialog> rval(new solution_dialog);
+    rval->decref();
+    return rval;
   }
 
   void update()

Modified: branches/aptitude-0.3/aptitude/src/solution_screen.cc
==============================================================================
--- branches/aptitude-0.3/aptitude/src/solution_screen.cc	(original)
+++ branches/aptitude-0.3/aptitude/src/solution_screen.cc	Wed Sep 21 18:12:25 2005
@@ -1000,7 +1000,10 @@
   static ref_ptr<solution_examiner> create(const sigc::slot1<void, fragment *> &set_short_description,
 					   const sigc::slot1<void, aptitude_resolver_dep> &set_active_dep)
   {
-    return new solution_examiner(set_short_description, set_active_dep);
+    ref_ptr<solution_examiner>
+      rval(new solution_examiner(set_short_description, set_active_dep));
+    rval->decref();
+    return rval;
   }
 
   void update()

Modified: branches/aptitude-0.3/aptitude/src/ui.cc
==============================================================================
--- branches/aptitude-0.3/aptitude/src/ui.cc	(original)
+++ branches/aptitude-0.3/aptitude/src/ui.cc	Wed Sep 21 18:12:25 2005
@@ -1281,7 +1281,7 @@
 
 static void do_sweep()
 {
-  add_main_widget(new cmine, _("Minesweeper"), _("Waste time trying to find mines"), _("Minesweeper"));
+  add_main_widget(cmine::create(), _("Minesweeper"), _("Waste time trying to find mines"), _("Minesweeper"));
 }
 
 static void do_clean()

Modified: branches/aptitude-0.3/aptitude/src/view_changelog.cc
==============================================================================
--- branches/aptitude-0.3/aptitude/src/view_changelog.cc	(original)
+++ branches/aptitude-0.3/aptitude/src/view_changelog.cc	Wed Sep 21 18:12:25 2005
@@ -72,7 +72,10 @@
   create(pkg_changelog *cl,
 	 int x=0, int y=0, int width=0, int height=0)
   {
-    return new pkg_changelog_screen(cl, x, y, width, height);
+    ref_ptr<pkg_changelog_screen>
+      rval(new pkg_changelog_screen(cl, x, y, width, height));
+    rval->decref();
+    return rval;
   }
 
   virtual ~pkg_changelog_screen() {delete cl;}

Modified: branches/aptitude-0.3/aptitude/src/vscreen/vs_button.h
==============================================================================
--- branches/aptitude-0.3/aptitude/src/vscreen/vs_button.h	(original)
+++ branches/aptitude-0.3/aptitude/src/vscreen/vs_button.h	Wed Sep 21 18:12:25 2005
@@ -42,7 +42,10 @@
   static ref_ptr<vs_button>
   create(const std::wstring &label)
   {
-    return new vs_button(label);
+    ref_ptr<vs_button> rval(new vs_button(label));
+    // Remove the initial construction reference.
+    rval->decref();
+    return rval;
   }
 
   /** Instantiate a vs_button.
@@ -52,7 +55,9 @@
    */
   static ref_ptr<vs_button> create(fragment *label)
   {
-    return new vs_button(label);
+    ref_ptr<vs_button> rval(new vs_button(label));
+    rval->decref();
+    return rval;
   }
 
   /** Instantiate a vs_button.
@@ -62,7 +67,9 @@
    */
   static ref_ptr<vs_button> create(const std::string &label)
   {
-    return new vs_button(label);
+    ref_ptr<vs_button> rval(new vs_button(label));
+    rval->decref();
+    return rval;
   }
 
   void paint(const style &st);

Modified: branches/aptitude-0.3/aptitude/src/vscreen/vs_center.h
==============================================================================
--- branches/aptitude-0.3/aptitude/src/vscreen/vs_center.h	(original)
+++ branches/aptitude-0.3/aptitude/src/vscreen/vs_center.h	Wed Sep 21 18:12:25 2005
@@ -17,7 +17,9 @@
 public:
   static ref_ptr<vs_center> create(const vs_widget_ref &w = NULL)
   {
-    return new vs_center(w);
+    ref_ptr<vs_center> rval(new vs_center(w));
+    rval->decref();
+    return rval;
   }
 
   int width_request();

Modified: branches/aptitude-0.3/aptitude/src/vscreen/vs_editline.h
==============================================================================
--- branches/aptitude-0.3/aptitude/src/vscreen/vs_editline.h	(original)
+++ branches/aptitude-0.3/aptitude/src/vscreen/vs_editline.h	Wed Sep 21 18:12:25 2005
@@ -67,28 +67,36 @@
   create(const std::wstring &prompt, const std::wstring &text = L"",
 	 history_list *history = NULL)
   {
-    return new vs_editline(prompt, text, history);
+    ref_ptr<vs_editline> rval(new vs_editline(prompt, text, history));
+    rval->decref();
+    return rval;
   }
 
   static ref_ptr<vs_editline>
   create(const std::string &prompt, const std::string &text = "",
 	 history_list *history = NULL)
   {
-    return new vs_editline(prompt, text, history);
+    ref_ptr<vs_editline> rval(new vs_editline(prompt, text, history));
+    rval->decref();
+    return rval;
   }
 
   static ref_ptr<vs_editline>
   create(int maxlength, const std::wstring &prompt,
 	 const std::wstring &text = L"", history_list *history = NULL)
   {
-    return new vs_editline(maxlength, prompt, text, history);
+    ref_ptr<vs_editline> rval(new vs_editline(maxlength, prompt, text, history));
+    rval->decref();
+    return rval;
   }
 
   static ref_ptr<vs_editline>
   create(int maxlength, const std::string &prompt,
 	 const std::string &text = "", history_list *history = NULL)
   {
-    return new vs_editline(maxlength, prompt, text, history);
+    ref_ptr<vs_editline> rval(new vs_editline(maxlength, prompt, text, history));
+    rval->decref();
+    return rval;
   }
 
   bool focus_me();

Modified: branches/aptitude-0.3/aptitude/src/vscreen/vs_frame.h
==============================================================================
--- branches/aptitude-0.3/aptitude/src/vscreen/vs_frame.h	(original)
+++ branches/aptitude-0.3/aptitude/src/vscreen/vs_frame.h	Wed Sep 21 18:12:25 2005
@@ -18,7 +18,9 @@
 public:
   static ref_ptr<vs_frame> create(const vs_widget_ref &w)
   {
-    return new vs_frame(w);
+    ref_ptr<vs_frame> rval(new vs_frame(w));
+    rval->decref();
+    return rval;
   }
 
   /** \return the desired width of the frame.  A frame is 2 larger

Modified: branches/aptitude-0.3/aptitude/src/vscreen/vs_label.cc
==============================================================================
--- branches/aptitude-0.3/aptitude/src/vscreen/vs_label.cc	(original)
+++ branches/aptitude-0.3/aptitude/src/vscreen/vs_label.cc	Wed Sep 21 18:12:25 2005
@@ -40,22 +40,30 @@
 
 vs_label_ref vs_label::create(const string &txt, const style &st)
 {
-  return new vs_label(txt, st);
+  vs_label_ref rval(new vs_label(txt, st));
+  rval->decref();
+  return rval;
 }
 
 vs_label_ref vs_label::create(const string &txt)
 {
-  return new vs_label(txt);
+  vs_label_ref rval(new vs_label(txt));
+  rval->decref();
+  return rval;
 }
 
 vs_label_ref vs_label::create(const wstring &txt, const style &st)
 {
-  return new vs_label(txt, st);
+  vs_label_ref rval(new vs_label(txt, st));
+  rval->decref();
+  return rval;
 }
 
 vs_label_ref vs_label::create(const wstring &txt)
 {
-  return new vs_label(txt);
+  vs_label_ref rval(new vs_label(txt));
+  rval->decref();
+  return rval;
 }
 
 vs_label::~vs_label()

Modified: branches/aptitude-0.3/aptitude/src/vscreen/vs_label.h
==============================================================================
--- branches/aptitude-0.3/aptitude/src/vscreen/vs_label.h	(original)
+++ branches/aptitude-0.3/aptitude/src/vscreen/vs_label.h	Wed Sep 21 18:12:25 2005
@@ -30,7 +30,9 @@
 public:
   static ref_ptr<vs_label> create(fragment *f)
   {
-    return new vs_label(f);
+    ref_ptr<vs_label> rval(new vs_label(f));
+    rval->decref();
+    return rval;
   }
 
   /** Create a vs_label with the given text and background. */

Modified: branches/aptitude-0.3/aptitude/src/vscreen/vs_menu.h
==============================================================================
--- branches/aptitude-0.3/aptitude/src/vscreen/vs_menu.h	(original)
+++ branches/aptitude-0.3/aptitude/src/vscreen/vs_menu.h	Wed Sep 21 18:12:25 2005
@@ -163,12 +163,16 @@
 public:
   static ref_ptr<vs_menu> create()
   {
-    return new vs_menu;
+    ref_ptr<vs_menu> rval(new vs_menu);
+    rval->decref();
+    return rval;
   }
 
   static ref_ptr<vs_menu> create(int x, int y, int w, vs_menu_info *inf)
   {
-    return new vs_menu(x, y, w, inf);
+    ref_ptr<vs_menu> rval(new vs_menu(x, y, w, inf));
+    rval->decref();
+    return rval;
   }
 
   // Deletes the items it holds!

Modified: branches/aptitude-0.3/aptitude/src/vscreen/vs_menubar.h
==============================================================================
--- branches/aptitude-0.3/aptitude/src/vscreen/vs_menubar.h	(original)
+++ branches/aptitude-0.3/aptitude/src/vscreen/vs_menubar.h	Wed Sep 21 18:12:25 2005
@@ -75,7 +75,9 @@
 public:
   static ref_ptr<vs_menubar> create(bool always_visible = true)
   {
-    return new vs_menubar(always_visible);
+    ref_ptr<vs_menubar> rval(new vs_menubar(always_visible));
+    rval->decref();
+    return rval;
   }
 
   ~vs_menubar();

Modified: branches/aptitude-0.3/aptitude/src/vscreen/vs_minibuf_win.h
==============================================================================
--- branches/aptitude-0.3/aptitude/src/vscreen/vs_minibuf_win.h	(original)
+++ branches/aptitude-0.3/aptitude/src/vscreen/vs_minibuf_win.h	Wed Sep 21 18:12:25 2005
@@ -57,7 +57,9 @@
   static
   ref_ptr<vs_minibuf_win> create()
   {
-    return new vs_minibuf_win;
+    ref_ptr<vs_minibuf_win> rval = new vs_minibuf_win;
+    rval->decref();
+    return rval;
   }
 
   ~vs_minibuf_win();

Modified: branches/aptitude-0.3/aptitude/src/vscreen/vs_multiplex.h
==============================================================================
--- branches/aptitude-0.3/aptitude/src/vscreen/vs_multiplex.h	(original)
+++ branches/aptitude-0.3/aptitude/src/vscreen/vs_multiplex.h	Wed Sep 21 18:12:25 2005
@@ -84,7 +84,9 @@
 public:
   static ref_ptr<vs_multiplex> create(bool show_tabs = false)
   {
-    return new vs_multiplex(show_tabs);
+    ref_ptr<vs_multiplex> rval(new vs_multiplex(show_tabs));
+    rval->decref();
+    return rval;
   }
 
   virtual ~vs_multiplex();

Modified: branches/aptitude-0.3/aptitude/src/vscreen/vs_pager.h
==============================================================================
--- branches/aptitude-0.3/aptitude/src/vscreen/vs_pager.h	(original)
+++ branches/aptitude-0.3/aptitude/src/vscreen/vs_pager.h	Wed Sep 21 18:12:25 2005
@@ -55,7 +55,9 @@
   static ref_ptr<vs_pager>
   create(const char *text, int len, const char *encoding = NULL)
   {
-    return new vs_pager(text, len, encoding);
+    ref_ptr<vs_pager> rval(new vs_pager(text, len, encoding));
+    rval->decref();
+    return rval;
   }
 
   /** Create a vs_pager from a string.
@@ -66,7 +68,9 @@
   static ref_ptr<vs_pager>
   create(const std::string &s, const char *encoding = NULL)
   {
-    return new vs_pager(s, encoding);
+    ref_ptr<vs_pager> rval(new vs_pager(s, encoding));
+    rval->decref();
+    return rval;
   }
 
   /** Create a vs_pager from a wide character string.
@@ -76,7 +80,11 @@
   static ref_ptr<vs_pager>
   create (const std::wstring &s)
   {
-    return new vs_pager(s);
+    ref_ptr<vs_pager> rval(new vs_pager(s));
+
+    rval->decref();
+
+    return rval;
   }
 
   /** Destroy this vs_pager. */

Modified: branches/aptitude-0.3/aptitude/src/vscreen/vs_scrollbar.h
==============================================================================
--- branches/aptitude-0.3/aptitude/src/vscreen/vs_scrollbar.h	(original)
+++ branches/aptitude-0.3/aptitude/src/vscreen/vs_scrollbar.h	Wed Sep 21 18:12:25 2005
@@ -36,13 +36,17 @@
   static
   ref_ptr<vs_scrollbar> create(direction dir, int val, int max)
   {
-    return new vs_scrollbar(dir, val, max);
+    ref_ptr<vs_scrollbar> rval(new vs_scrollbar(dir, val, max));
+    rval->decref();
+    return rval;
   }
 
   static
   ref_ptr<vs_scrollbar> create(direction dir)
   {
-    return new vs_scrollbar(dir);
+    ref_ptr<vs_scrollbar> rval(new vs_scrollbar(dir));
+    rval->decref();
+    return rval;
   }
 
   void paint(const style &st);

Modified: branches/aptitude-0.3/aptitude/src/vscreen/vs_size_box.h
==============================================================================
--- branches/aptitude-0.3/aptitude/src/vscreen/vs_size_box.h	(original)
+++ branches/aptitude-0.3/aptitude/src/vscreen/vs_size_box.h	Wed Sep 21 18:12:25 2005
@@ -31,7 +31,9 @@
    */
   static ref_ptr<vs_size_box> create(size s, const vs_widget_ref &w=NULL)
   {
-    return new vs_size_box(s, w);
+    ref_ptr<vs_size_box> rval(new vs_size_box(s, w));
+    rval->decref();
+    return rval;
   }
 
   /** \return the least upper bound of the minimum size passed to the

Modified: branches/aptitude-0.3/aptitude/src/vscreen/vs_stacked.h
==============================================================================
--- branches/aptitude-0.3/aptitude/src/vscreen/vs_stacked.h	(original)
+++ branches/aptitude-0.3/aptitude/src/vscreen/vs_stacked.h	Wed Sep 21 18:12:25 2005
@@ -54,7 +54,9 @@
 
   static ref_ptr<vs_stacked> create(int w=0, int h=0)
   {
-    return new vs_stacked(w, h);
+    ref_ptr<vs_stacked> rval(new vs_stacked(w, h));
+    rval->decref();
+    return rval;
   }
 
   void add_widget(const vs_widget_ref &w);

Modified: branches/aptitude-0.3/aptitude/src/vscreen/vs_statuschoice.h
==============================================================================
--- branches/aptitude-0.3/aptitude/src/vscreen/vs_statuschoice.h	(original)
+++ branches/aptitude-0.3/aptitude/src/vscreen/vs_statuschoice.h	Wed Sep 21 18:12:25 2005
@@ -55,7 +55,9 @@
   static ref_ptr<vs_statuschoice> create(const std::wstring &prompt,
 					 const std::wstring &choices)
   {
-    return new vs_statuschoice(prompt, choices);
+    ref_ptr<vs_statuschoice> rval(new vs_statuschoice(prompt, choices));
+    rval->decref();
+    return rval;
   }
 
   int width_request();

Modified: branches/aptitude-0.3/aptitude/src/vscreen/vs_table.h
==============================================================================
--- branches/aptitude-0.3/aptitude/src/vscreen/vs_table.h	(original)
+++ branches/aptitude-0.3/aptitude/src/vscreen/vs_table.h	Wed Sep 21 18:12:25 2005
@@ -150,7 +150,9 @@
 public:
   static ref_ptr<vs_table> create()
   {
-    return new vs_table;
+    ref_ptr<vs_table> rval(new vs_table);
+    rval->decref();
+    return rval;
   }
 
   ~vs_table();

Modified: branches/aptitude-0.3/aptitude/src/vscreen/vs_text_layout.h
==============================================================================
--- branches/aptitude-0.3/aptitude/src/vscreen/vs_text_layout.h	(original)
+++ branches/aptitude-0.3/aptitude/src/vscreen/vs_text_layout.h	Wed Sep 21 18:12:25 2005
@@ -34,7 +34,9 @@
   /** Create an empty vs_text_layout. */
   static ref_ptr<vs_text_layout> create()
   {
-    return new vs_text_layout;
+    ref_ptr<vs_text_layout> rval(new vs_text_layout);
+    rval->decref();
+    return rval;
   }
 
   /** Create a vs_text_layout with the given root fragment.
@@ -44,7 +46,9 @@
    */
   static ref_ptr<vs_text_layout> create(fragment *f)
   {
-    return new vs_text_layout(f);
+    ref_ptr<vs_text_layout> rval(new vs_text_layout(f));
+    rval->decref();
+    return rval;
   }
 
   /** Handle the given keypress.  Returns \b true if the keystroke

Modified: branches/aptitude-0.3/aptitude/src/vscreen/vs_togglebutton.h
==============================================================================
--- branches/aptitude-0.3/aptitude/src/vscreen/vs_togglebutton.h	(original)
+++ branches/aptitude-0.3/aptitude/src/vscreen/vs_togglebutton.h	Wed Sep 21 18:12:25 2005
@@ -33,16 +33,22 @@
   create(char bracketl, char mark, char bracketr,
 	 fragment *label, bool checked = false)
   {
-    return new vs_togglebutton(bracketl, mark, bracketr,
-			       label, checked);
+    ref_ptr<vs_togglebutton>
+      rval(new vs_togglebutton(bracketl, mark, bracketr,
+			       label, checked));
+    rval->decref();
+    return rval;
   }
 
   static ref_ptr<vs_togglebutton>
   create(char bracketl, char mark, char bracketr,
 	 const std::string &label, bool checked = false)
   {
-    return new vs_togglebutton(bracketl, mark, bracketr,
-			       label, checked);
+    ref_ptr<vs_togglebutton>
+      rval(new vs_togglebutton(bracketl, mark, bracketr,
+			       label, checked));
+    rval->decref();
+    return rval;
   }
 
   point get_cursorloc();

Modified: branches/aptitude-0.3/aptitude/src/vscreen/vs_transient.h
==============================================================================
--- branches/aptitude-0.3/aptitude/src/vscreen/vs_transient.h	(original)
+++ branches/aptitude-0.3/aptitude/src/vscreen/vs_transient.h	Wed Sep 21 18:12:25 2005
@@ -29,7 +29,9 @@
   static ref_ptr<vs_transient>
   create(const vs_widget_ref &w = NULL)
   {
-    return new vs_transient(w);
+    ref_ptr<vs_transient> rval(new vs_transient(w));
+    rval->decref();
+    return rval;
   }
 
   /** \return the desired width of the subwidget. */

Modified: branches/aptitude-0.3/aptitude/src/vscreen/vs_tree.h
==============================================================================
--- branches/aptitude-0.3/aptitude/src/vscreen/vs_tree.h	(original)
+++ branches/aptitude-0.3/aptitude/src/vscreen/vs_tree.h	Wed Sep 21 18:12:25 2005
@@ -117,13 +117,17 @@
   static ref_ptr<vs_tree>
   create()
   {
-    return new vs_tree;
+    ref_ptr<vs_tree> rval(new vs_tree);
+    rval->decref();
+    return rval;
   }
 
   static ref_ptr<vs_tree>
   create(vs_treeitem *root, bool showroot = false)
   {
-    return new vs_tree(root, showroot);
+    ref_ptr<vs_tree> rval(new vs_tree(root, showroot));
+    rval->decref();
+    return rval;
   }
 
   void set_root(vs_treeitem *_root, bool showroot=false);

Modified: branches/aptitude-0.3/aptitude/src/vscreen/vscreen_widget.h
==============================================================================
--- branches/aptitude-0.3/aptitude/src/vscreen/vscreen_widget.h	(original)
+++ branches/aptitude-0.3/aptitude/src/vscreen/vscreen_widget.h	Wed Sep 21 18:12:25 2005
@@ -125,7 +125,9 @@
   style bg_style;
 
   /** The number of live references to this object.  This is initially
-   *  0, to support the use of the generic refcounting wrapper.
+   *  1, so that it's safe to take references in the constructor.  It
+   *  is expected that subclasses will only permit construction via
+   *  static methods that remove this initial reference.
    */
   mutable int refcount;
 



More information about the Aptitude-svn-commit mailing list