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

Daniel Burrows dburrows at costa.debian.org
Wed Sep 21 05:49:32 UTC 2005


Author: dburrows
Date: Wed Sep 21 05:49:28 2005
New Revision: 4146

Modified:
   branches/aptitude-0.3/aptitude/ChangeLog
   branches/aptitude-0.3/aptitude/src/solution_screen.cc
Log:
Fix a memory disaster by strategically taking a self-reference.

Modified: branches/aptitude-0.3/aptitude/ChangeLog
==============================================================================
--- branches/aptitude-0.3/aptitude/ChangeLog	(original)
+++ branches/aptitude-0.3/aptitude/ChangeLog	Wed Sep 21 05:49:28 2005
@@ -2,6 +2,12 @@
 
 	* src/solution_screen.cc:
 
+	  Have the examiner take a reference to itself in the destroy()
+	  call; fixes a crash due to accessing members of the examiner
+	  after it's deleted by destroy().
+
+	* src/solution_screen.cc:
+
 	  Clear out the other information areas when the multiplex goes.
 
 	* src/vscreen/vs_multiplex.cc, src/vscreen/vs_table.cc:

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 05:49:28 2005
@@ -978,7 +978,9 @@
 
     vscreen_addtimeout(new slot_event(sigc::mem_fun(this, &solution_examiner::tick)), 1000);
 
-    update();
+    // Because the update event might destroy this object, it needs to
+    // take place after the constructor returns.
+    vscreen_post_event(new slot_event(sigc::mem_fun(this, &solution_examiner::update)));
   }
 
   bool handle_key(const key &k)
@@ -999,6 +1001,8 @@
 
   void update()
   {
+    ref_ptr<solution_examiner> tmpref(this);
+
     if(!apt_cache_file)
       {
 	set_static_root(transcode(_("The package cache is not available.")));



More information about the Aptitude-svn-commit mailing list