[Aptitude-svn-commit] r3758 - in branches/aptitude-0.3/aptitude: .
src/vscreen
Daniel Burrows
dburrows at costa.debian.org
Mon Aug 8 22:35:43 UTC 2005
Author: dburrows
Date: Mon Aug 8 22:35:40 2005
New Revision: 3758
Modified:
branches/aptitude-0.3/aptitude/ChangeLog
branches/aptitude-0.3/aptitude/src/vscreen/testvscreen.cc
branches/aptitude-0.3/aptitude/src/vscreen/vscreen.cc
branches/aptitude-0.3/aptitude/src/vscreen/vscreen.h
Log:
Work out a new, safer way of handling the top-level widget that should
eliminate one source of crashes on exit.
Modified: branches/aptitude-0.3/aptitude/ChangeLog
==============================================================================
--- branches/aptitude-0.3/aptitude/ChangeLog (original)
+++ branches/aptitude-0.3/aptitude/ChangeLog Mon Aug 8 22:35:40 2005
@@ -1,5 +1,14 @@
2005-08-08 Daniel Burrows <dburrows at debian.org>
+ * src/ui.cc, src/vscreen/testvscreen.cc, src/vscreen/vscreen.cc, src/vscreen/vscreen.h:
+
+ Update the handling of the top-level widget: you should now call
+ vscreen_shutdown() when shutting the program down instead of
+ rootwin.endwin(), which will destroy and drop the top-level
+ widget; and you can retrieve the old top-level when setting up a
+ new one (in fact, you must, in order to make sure that destroy()
+ is called before deleting the pointer).
+
* src/vscreen/vscreen_widget.cc:
Don't call destroy() from the destructor, and don't bother
@@ -11,7 +20,8 @@
Incidentally, calling destroy() from the destructor was a truly
awful idea -- not only is it a complex member function, it's
- virtual!
+ virtual! [EDIT: doh, it wasn't being called from a destructor.
+ Please ignore my stupidity]
* src/vscreen/vs_radiogroup.cc:
Modified: branches/aptitude-0.3/aptitude/src/vscreen/testvscreen.cc
==============================================================================
--- branches/aptitude-0.3/aptitude/src/vscreen/testvscreen.cc (original)
+++ branches/aptitude-0.3/aptitude/src/vscreen/testvscreen.cc Mon Aug 8 22:35:40 2005
@@ -495,10 +495,7 @@
vscreen_mainloop();
- rootwin.bkgdset(' ');
- rootwin.clear();
- rootwin.refresh();
- endwin();
+ vscreen_shutdown();
return 0;
}
Modified: branches/aptitude-0.3/aptitude/src/vscreen/vscreen.cc
==============================================================================
--- branches/aptitude-0.3/aptitude/src/vscreen/vscreen.cc (original)
+++ branches/aptitude-0.3/aptitude/src/vscreen/vscreen.cc Mon Aug 8 22:35:40 2005
@@ -170,12 +170,14 @@
}
///////////////////////////////////////////////////////////////////////////////
-void vscreen_settoplevel(const vs_widget_ref &w)
+vs_widget_ref vscreen_settoplevel(const vs_widget_ref &w)
{
if(toplevel.valid())
toplevel->unfocussed();
- toplevel=w;
+ vs_widget_ref oldw = toplevel;
+
+ toplevel = w;
if(curses_avail)
{
@@ -184,6 +186,8 @@
toplevel->focussed();
vscreen_redraw();
}
+
+ return oldw;
}
void vscreen_init()
@@ -646,6 +650,10 @@
{
if(toplevel.valid())
toplevel->set_owner_window(NULL, 0, 0, 0, 0);
+
+ rootwin.bkgdset(' ');
+ rootwin.clear();
+ rootwin.refresh();
endwin();
curses_avail=false;
}
@@ -667,6 +675,14 @@
vscreen_suspend_without_signals();
}
+void vscreen_shutdown()
+{
+ toplevel->destroy();
+ toplevel = NULL;
+
+ vscreen_suspend();
+}
+
void vscreen_resume()
{
if(suspended_with_signals)
Modified: branches/aptitude-0.3/aptitude/src/vscreen/vscreen.h
==============================================================================
--- branches/aptitude-0.3/aptitude/src/vscreen/vscreen.h (original)
+++ branches/aptitude-0.3/aptitude/src/vscreen/vscreen.h Mon Aug 8 22:35:40 2005
@@ -41,8 +41,12 @@
// cleanly shut the program down. This can be called after the
// program starts to re-initialize the display code.
-void vscreen_settoplevel(const ref_ptr<vscreen_widget> &widget);
-// Changes the toplevel widget
+/** Sets the top-level widget to the new value, returning the old
+ * top-level widget. If the top-level widget is to be destroyed,
+ * IT IS THE CALLER'S RESPONSIBILITY TO CALL destroy() BEFORE
+ * DISCARDING THE REFERENCE!
+ */
+ref_ptr<vscreen_widget> vscreen_settoplevel(const ref_ptr<vscreen_widget> &widget);
void vscreen_queuelayout();
// Queues a re-layout of all widgets (needed when something has to be resized)
@@ -92,6 +96,12 @@
*/
void vscreen_suspend_without_signals();
+/** Does the same thing as vscreen_suspend, except that it also
+ * destroys the top-level widget. Call this when the program is
+ * exiting.
+ */
+void vscreen_shutdown();
+
/** Returns to Curses mode after a vscreen_suspend*, restoring any
* signal handlers that were modified by the suspend routine.
*/
More information about the Aptitude-svn-commit
mailing list