[Aptitude-svn-commit] r4148 - in branches/aptitude-0.3/aptitude: .
src src/mine src/vscreen
Daniel Burrows
dburrows at costa.debian.org
Wed Sep 21 17:16:56 UTC 2005
Author: dburrows
Date: Wed Sep 21 17:16:51 2005
New Revision: 4148
Modified:
branches/aptitude-0.3/aptitude/ChangeLog
branches/aptitude-0.3/aptitude/src/apt_info_tree.cc
branches/aptitude-0.3/aptitude/src/broken_indicator.cc
branches/aptitude-0.3/aptitude/src/download_bar.cc
branches/aptitude-0.3/aptitude/src/download_list.cc
branches/aptitude-0.3/aptitude/src/download_screen.cc
branches/aptitude-0.3/aptitude/src/edit_pkg_hier.cc
branches/aptitude-0.3/aptitude/src/mine/cmine.cc
branches/aptitude-0.3/aptitude/src/pkg_info_screen.cc
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/vscreen/vs_bin.cc
branches/aptitude-0.3/aptitude/src/vscreen/vs_button.cc
branches/aptitude-0.3/aptitude/src/vscreen/vs_center.cc
branches/aptitude-0.3/aptitude/src/vscreen/vs_container.cc
branches/aptitude-0.3/aptitude/src/vscreen/vs_editline.cc
branches/aptitude-0.3/aptitude/src/vscreen/vs_frame.cc
branches/aptitude-0.3/aptitude/src/vscreen/vs_label.cc
branches/aptitude-0.3/aptitude/src/vscreen/vs_menu.cc
branches/aptitude-0.3/aptitude/src/vscreen/vs_menubar.cc
branches/aptitude-0.3/aptitude/src/vscreen/vs_minibuf_win.cc
branches/aptitude-0.3/aptitude/src/vscreen/vs_multiplex.cc
branches/aptitude-0.3/aptitude/src/vscreen/vs_pager.cc
branches/aptitude-0.3/aptitude/src/vscreen/vs_passthrough.cc
branches/aptitude-0.3/aptitude/src/vscreen/vs_scrollbar.cc
branches/aptitude-0.3/aptitude/src/vscreen/vs_size_box.cc
branches/aptitude-0.3/aptitude/src/vscreen/vs_stacked.cc
branches/aptitude-0.3/aptitude/src/vscreen/vs_statuschoice.cc
branches/aptitude-0.3/aptitude/src/vscreen/vs_table.cc
branches/aptitude-0.3/aptitude/src/vscreen/vscreen_widget.cc
Log:
Take many more precautionary self-references.
Modified: branches/aptitude-0.3/aptitude/ChangeLog
==============================================================================
--- branches/aptitude-0.3/aptitude/ChangeLog (original)
+++ branches/aptitude-0.3/aptitude/ChangeLog Wed Sep 21 17:16:51 2005
@@ -1,3 +1,12 @@
+2005-09-21 Daniel Burrows <dburrows at debian.org>
+
+ * 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
+ (in particular, any routine that invokes a virtual method or a
+ signal) in order to avoid future surprises like the one that
+ wasted so much time yesterday.
+
2005-09-20 Daniel Burrows <dburrows at debian.org>
* src/apt_info_tree.cc:
Modified: branches/aptitude-0.3/aptitude/src/apt_info_tree.cc
==============================================================================
--- branches/aptitude-0.3/aptitude/src/apt_info_tree.cc (original)
+++ branches/aptitude-0.3/aptitude/src/apt_info_tree.cc Wed Sep 21 17:16:51 2005
@@ -37,7 +37,7 @@
void apt_info_tree::restore_state()
{
- ref_ptr<apt_info_tree> tmpref(this);
+ vs_widget_ref tmpref(this);
reset_incsearch();
@@ -67,5 +67,7 @@
void apt_info_tree::repeat_signal()
{
+ vs_widget_ref tmpref(this);
+
get_selected()->highlighted(this);
}
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 17:16:51 2005
@@ -119,6 +119,8 @@
void tick_timeout()
{
+ vs_widget_ref tmpref(this);
+
if(resman->background_thread_active())
{
++spin_count;
@@ -183,6 +185,8 @@
// TODO: split this monster up.
void update()
{
+ vs_widget_ref tmpref(this);
+
if((!apt_cache_file) || !resman->resolver_exists())
{
set_fragment(fragf(""));
Modified: branches/aptitude-0.3/aptitude/src/download_bar.cc
==============================================================================
--- branches/aptitude-0.3/aptitude/src/download_bar.cc (original)
+++ branches/aptitude-0.3/aptitude/src/download_bar.cc Wed Sep 21 17:16:51 2005
@@ -44,6 +44,8 @@
bool download_status_bar::MediaChange(string media, string drive)
{
+ vs_widget_ref tmpref(this);
+
fragment *f=wrapbox(fragf(_("Please insert the disc labeled \"%s\" into the drive \"%s\""),
media.c_str(), drive.c_str()));
@@ -59,6 +61,8 @@
void download_status_bar::IMSHit(pkgAcquire::ItemDesc &itm)
{
+ vs_widget_ref tmpref(this);
+
last_msg=_("Hit ")+itm.Description;
last_switchtime=time(0);
@@ -68,6 +72,8 @@
void download_status_bar::Fetch(pkgAcquire::ItemDesc &itm)
{
+ vs_widget_ref tmpref(this);
+
last_msg=_("Downloading ")+itm.ShortDesc;
last_switchtime=time(0);
@@ -77,6 +83,8 @@
void download_status_bar::Done(pkgAcquire::ItemDesc &itm)
{
+ vs_widget_ref tmpref(this);
+
last_msg=_("Got ")+itm.Description;
last_switchtime=time(0);
@@ -86,6 +94,8 @@
void download_status_bar::Fail(pkgAcquire::ItemDesc &itm)
{
+ vs_widget_ref tmpref(this);
+
last_msg=itm.Description+": "+itm.Owner->ErrorText;
last_switchtime=time(0);
@@ -95,6 +105,8 @@
bool download_status_bar::Pulse(pkgAcquire *Owner)
{
+ vs_widget_ref tmpref(this);
+
pkgAcquireStatus::Pulse(Owner);
if(difftime(time(0), last_switchtime)>1)
@@ -152,6 +164,8 @@
void download_status_bar::paint(const style &st)
{
+ vs_widget_ref tmpref(this);
+
int width=getmaxx();
string todisp=last_msg,totalprogress;
@@ -191,11 +205,15 @@
void download_status_bar::Start()
{
+ vs_widget_ref tmpref(this);
+
pkgAcquireStatus::Start();
}
void download_status_bar::Stop()
{
+ vs_widget_ref tmpref(this);
+
pkgAcquireStatus::Stop();
destroy();
@@ -203,6 +221,8 @@
bool download_status_bar::handle_key(const key &k)
{
+ vs_widget_ref tmpref(this);
+
if(global_bindings.key_matches(k, "Quit"))
{
cancelled=true;
Modified: branches/aptitude-0.3/aptitude/src/download_list.cc
==============================================================================
--- branches/aptitude-0.3/aptitude/src/download_list.cc (original)
+++ branches/aptitude-0.3/aptitude/src/download_list.cc Wed Sep 21 17:16:51 2005
@@ -123,6 +123,8 @@
void download_list::paint(const style &st)
{
+ vs_widget_ref tmpref(this);
+
int y=0;
unsigned int where=start;
int width,height;
@@ -251,6 +253,8 @@
void download_list::update_workers(pkgAcquire *Owner)
{
+ vs_widget_ref tmpref(this);
+
int width,height;
getmaxyx(height, width);
@@ -300,6 +304,8 @@
download_manager &manager,
const sigc::slot1<void, bool> &k)
{
+ vs_widget_ref tmpref(this);
+
fragment *f=wrapbox(fragf(_("Please insert the disc labeled \"%s\" into the drive \"%s\""),
media.c_str(), drive.c_str()));
@@ -317,6 +323,8 @@
void download_list::IMSHit(pkgAcquire::ItemDesc &itmdesc,
download_manager &manager)
{
+ vs_widget_ref tmpref(this);
+
if(display_messages)
{
msgs.push_back(msg(transcode(itmdesc.Description+" "+_("[Hit]")),
@@ -337,6 +345,8 @@
void download_list::Done(pkgAcquire::ItemDesc &itmdesc,
download_manager &manager)
{
+ vs_widget_ref tmpref(this);
+
if(display_messages)
{
msgs.push_back(msg(transcode(itmdesc.Description+" "+_("[Downloaded]")),
@@ -352,6 +362,8 @@
void download_list::Fail(pkgAcquire::ItemDesc &itmdesc,
download_manager &manager)
{
+ vs_widget_ref tmpref(this);
+
if(display_messages)
{
if(itmdesc.Owner->Status==pkgAcquire::Item::StatIdle)
@@ -380,6 +392,8 @@
void download_list::Start(download_manager &manager)
{
+ vs_widget_ref tmpref(this);
+
// Delete stuff from previous runs (eg, for multiple CDs)
workers.erase(workers.begin(), workers.end());
msgs.erase(msgs.begin(), msgs.end());
@@ -387,6 +401,8 @@
void download_list::Stop(download_manager &manager, const sigc::slot0<void> &k)
{
+ vs_widget_ref tmpref(this);
+
string s=aptcfg->Find(PACKAGE "::UI::Pause-After-Download", "OnlyIfError");
bool show_summary=false;
@@ -423,6 +439,8 @@
void download_list::Pulse(pkgAcquire *Owner, download_manager &manager,
const sigc::slot1<void, bool> &k)
{
+ vs_widget_ref tmpref(this);
+
TotalBytes=manager.get_total_bytes();
TotalItems=manager.get_total_items();
CurrentBytes=manager.get_current_bytes();
@@ -452,6 +470,8 @@
bool download_list::handle_key(const key &k)
{
+ vs_widget_ref tmpref(this);
+
if(global_bindings.key_matches(k, "NextPage"))
pagedown();
if(global_bindings.key_matches(k, "Down"))
Modified: branches/aptitude-0.3/aptitude/src/download_screen.cc
==============================================================================
--- branches/aptitude-0.3/aptitude/src/download_screen.cc (original)
+++ branches/aptitude-0.3/aptitude/src/download_screen.cc Wed Sep 21 17:16:51 2005
@@ -47,6 +47,8 @@
bool download_screen::MediaChange(string Media, string Drive)
{
+ vs_widget_ref tmpref(this);
+
char buf[512];
snprintf(buf, 512,
@@ -71,6 +73,8 @@
void download_screen::IMSHit(pkgAcquire::ItemDesc &itmdesc)
{
+ vs_widget_ref tmpref(this);
+
downloadmap::iterator found=active_items.find(itmdesc.Owner);
if(found==active_items.end())
@@ -88,6 +92,8 @@
void download_screen::Fetch(pkgAcquire::ItemDesc &itmdesc)
{
+ vs_widget_ref tmpref(this);
+
downloadmap::iterator found=active_items.find(itmdesc.Owner);
if(found==active_items.end())
@@ -104,6 +110,8 @@
void download_screen::Done(pkgAcquire::ItemDesc &itmdesc)
{
+ vs_widget_ref tmpref(this);
+
downloadmap::iterator found=active_items.find(itmdesc.Owner);
if(found==active_items.end())
{
@@ -124,6 +132,8 @@
void download_screen::Fail(pkgAcquire::ItemDesc &itmdesc)
{
+ vs_widget_ref tmpref(this);
+
downloadmap::iterator found=active_items.find(itmdesc.Owner);
if(found!=active_items.end())
found->second->set_worker(NULL);
@@ -135,6 +145,8 @@
bool download_screen::Pulse(pkgAcquire *Owner)
{
+ vs_widget_ref tmpref(this);
+
pkgAcquireStatus::Pulse(Owner);
for(pkgAcquire::Worker *i=Owner->WorkersBegin(); i; i=Owner->WorkerStep(i))
@@ -153,11 +165,15 @@
void download_screen::Start()
{
+ vs_widget_ref tmpref(this);
+
pkgAcquireStatus::Start();
}
void download_screen::Stop()
{
+ vs_widget_ref tmpref(this);
+
char buf[256];
pkgAcquireStatus::Stop();
@@ -215,6 +231,8 @@
bool download_screen::handle_key(const key &k)
{
+ vs_widget_ref tmpref(this);
+
if(global_bindings.key_matches(k, "Quit"))
cancelled=true;
else
Modified: branches/aptitude-0.3/aptitude/src/edit_pkg_hier.cc
==============================================================================
--- branches/aptitude-0.3/aptitude/src/edit_pkg_hier.cc (original)
+++ branches/aptitude-0.3/aptitude/src/edit_pkg_hier.cc Wed Sep 21 17:16:51 2005
@@ -156,6 +156,8 @@
void vs_hier_editor::handle_reload()
{
+ vs_widget_ref tmpref(this);
+
set_root(NULL);
items.clear();
@@ -186,6 +188,8 @@
// (yes, it would be nicer in some ways to not recreate the tree continually)
void vs_hier_editor::set_package(const pkgCache::PkgIterator &pkg)
{
+ vs_widget_ref tmpref(this);
+
shown_conn.disconnect();
if(get_visible())
{
Modified: branches/aptitude-0.3/aptitude/src/mine/cmine.cc
==============================================================================
--- branches/aptitude-0.3/aptitude/src/mine/cmine.cc (original)
+++ branches/aptitude-0.3/aptitude/src/mine/cmine.cc Wed Sep 21 17:16:51 2005
@@ -96,6 +96,8 @@
void cmine::paint_header(const style &st)
// Shows the header with its extra info
{
+ vs_widget_ref tmpref(this);
+
if(board)
{
int width,height;
@@ -149,6 +151,8 @@
void cmine::do_load_game(wstring ws)
{
+ vs_widget_ref tmpref(this);
+
string s=transcode(ws);
if(s!="")
@@ -191,6 +195,8 @@
void cmine::do_save_game(wstring ws)
{
+ vs_widget_ref tmpref(this);
+
string s=transcode(ws);
if(s!="")
@@ -218,6 +224,8 @@
vs_editline &widthedit_bare,
vs_editline &minesedit_bare)
{
+ vs_widget_ref tmpref(this);
+
// Be ultra-safe and hold strong references to everything.
vs_widget_ref w(&w_bare);
vs_editline_ref heightedit(&heightedit_bare),
@@ -273,6 +281,8 @@
void cmine::do_custom_game()
{
+ vs_widget_ref tmpref(this);
+
vs_center_ref center=vs_center::create();
center->set_bg_style(style_attrs_flip(A_REVERSE));
@@ -340,6 +350,8 @@
void cmine::do_new_game()
{
+ vs_widget_ref tmpref(this);
+
vs_center_ref center=vs_center::create();
center->set_bg_style(style_attrs_flip(A_REVERSE));
@@ -398,6 +410,8 @@
vscreen_widget &w_bare,
vs_radiogroup *grp)
{
+ vs_widget_ref tmpref(this);
+
vs_widget_ref w(&w_bare);
if(start)
@@ -436,6 +450,8 @@
void cmine::checkend()
// Prints out silly messages when the player wins or loses
{
+ vs_widget_ref tmpref(this);
+
if(board->get_state()==mine_board::won)
// "You hold up the Amulet of Yendor. An invisible choir sings..."
popup_widget(vs_dialog_ok(transcode(_("You have won."))));
@@ -557,6 +573,8 @@
bool cmine::handle_key(const key &k)
{
+ vs_widget_ref tmpref(this);
+
int width,height;
getmaxyx(height, width);
Modified: branches/aptitude-0.3/aptitude/src/pkg_info_screen.cc
==============================================================================
--- branches/aptitude-0.3/aptitude/src/pkg_info_screen.cc (original)
+++ branches/aptitude-0.3/aptitude/src/pkg_info_screen.cc Wed Sep 21 17:16:51 2005
@@ -72,7 +72,6 @@
pkg_item_with_generic_subtree *tree,
pkg_signal *sig)
{
-
char buf[256];
if(!ver.end())
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 17:16:51 2005
@@ -106,6 +106,8 @@
void paint(const style &st)
{
+ vs_widget_ref tmpref(this);
+
if(apt_cache_file)
{
// Needed to initialize translated widths and stuff.
@@ -264,6 +266,8 @@
void line_up()
{
+ vs_widget_ref tmpref(this);
+
vs_widget_ref w=visible_widget();
if(w==description_table)
@@ -274,6 +278,8 @@
void line_down()
{
+ vs_widget_ref tmpref(this);
+
vs_widget_ref w=visible_widget();
if(w==description_table)
@@ -285,6 +291,8 @@
void set_package(const pkgCache::PkgIterator &pkg,
const pkgCache::VerIterator &ver)
{
+ vs_widget_ref tmpref(this);
+
bool hasBreakage;
description->set_package(pkg, ver);
@@ -328,6 +336,8 @@
/** Cycles the multiplex, taking autoswitch behavior into account. */
void cycle()
{
+ vs_widget_ref tmpref(this);
+
if(autoswitch.valid() && autoswitch!=visible_widget())
{
autoswitch->show();
@@ -355,6 +365,8 @@
*/
void set_description(const std::wstring &s)
{
+ vs_widget_ref tmpref(this);
+
if(s!=lastDesc)
{
lastDesc=s;
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 17:16:51 2005
@@ -97,6 +97,8 @@
void update()
{
+ vs_widget_ref tmpref(this);
+
if(!apt_cache_file)
{
set_fragment(fragf("%s", _("The package cache is not available.")));
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 17:16:51 2005
@@ -639,13 +639,11 @@
bool is_rejected()
{
return resman->is_hardened(d);
- return false;
}
bool is_mandatory()
{
return resman->is_forced_broken(d);
- return false;
}
void highlighted(vs_tree *win)
@@ -931,6 +929,8 @@
*/
void update_highlights()
{
+ vs_widget_ref tmpref(this);
+
if(solution_tree == visible_widget())
{
story_tree->unhighlight_current();
@@ -945,6 +945,8 @@
void tick()
{
+ vs_widget_ref tmpref(this);
+
if(resman != NULL && resman->resolver_exists())
{
resolver_manager::state state = resman->state_snapshot();
@@ -985,6 +987,8 @@
bool handle_key(const key &k)
{
+ vs_widget_ref tmpref(this);
+
if(global_bindings.key_matches(k, "CycleOrder"))
cycle_forward();
else
@@ -1026,6 +1030,8 @@
void update_from_state(const resolver_manager::state &state)
{
+ vs_widget_ref tmpref(this);
+
if(state.solutions_exhausted && state.generated_solutions == 0)
{
set_static_root(transcode(_("No resolution found.")));
@@ -1072,6 +1078,7 @@
update_highlights();
}
};
+
typedef ref_ptr<solution_examiner> solution_examiner_ref;
static
Modified: branches/aptitude-0.3/aptitude/src/vscreen/vs_bin.cc
==============================================================================
--- branches/aptitude-0.3/aptitude/src/vscreen/vs_bin.cc (original)
+++ branches/aptitude-0.3/aptitude/src/vscreen/vs_bin.cc Wed Sep 21 17:16:51 2005
@@ -20,6 +20,8 @@
vs_widget_ref vs_bin::get_focus()
{
+ vs_widget_ref tmpref(this);
+
vs_widget_ref w = subwidget;
if(w.valid() && w->get_visible())
@@ -30,6 +32,8 @@
void vs_bin::set_subwidget(const vs_widget_ref &w)
{
+ vs_widget_ref tmpref(this);
+
if(subwidget.valid())
{
subwidget->set_owner(NULL);
@@ -55,6 +59,8 @@
void vs_bin::destroy()
{
+ vs_widget_ref tmpref(this);
+
if(subwidget.valid())
subwidget->destroy();
assert(!subwidget.valid());
@@ -64,6 +70,8 @@
void vs_bin::add_widget(const vs_widget_ref &w)
{
+ vs_widget_ref tmpref(this);
+
assert(!subwidget.valid());
assert(w.valid());
@@ -79,6 +87,8 @@
void vs_bin::rem_widget(const vs_widget_ref &w)
{
+ vs_widget_ref tmpref(this);
+
assert(w == subwidget);
set_subwidget(NULL);
@@ -91,6 +101,8 @@
void vs_bin::show_all()
{
+ vs_widget_ref tmpref(this);
+
if(subwidget.valid())
subwidget->show_all();
@@ -99,6 +111,8 @@
void vs_bin::show_widget(const vs_widget_ref &w)
{
+ vs_widget_ref tmpref(this);
+
assert(w==subwidget);
show();
@@ -106,22 +120,30 @@
void vs_bin::show_widget_bare(vscreen_widget &w)
{
+ vs_widget_ref tmpref(this);
+
show_widget(vs_widget_ref(&w));
}
void vs_bin::hide_widget(const vs_widget_ref &w)
{
+ vs_widget_ref tmpref(this);
+
assert(w==subwidget);
hide();
}
void vs_bin::hide_widget_bare(vscreen_widget &w)
{
+ vs_widget_ref tmpref(this);
+
hide_widget(vs_widget_ref(&w));
}
void vs_bin::paint(const style &st)
{
+ vs_widget_ref tmpref(this);
+
if(subwidget.valid() && subwidget->get_visible())
subwidget->display(st);
}
Modified: branches/aptitude-0.3/aptitude/src/vscreen/vs_button.cc
==============================================================================
--- branches/aptitude-0.3/aptitude/src/vscreen/vs_button.cc (original)
+++ branches/aptitude-0.3/aptitude/src/vscreen/vs_button.cc Wed Sep 21 17:16:51 2005
@@ -63,6 +63,8 @@
void vs_button::paint(const style &st)
{
+ vs_widget_ref tmpref(this);
+
size_t labelw=getmaxx()>=4?getmaxx()-4:0;
const style my_style=
@@ -112,6 +114,8 @@
void vs_button::dispatch_mouse(short id, int x, int y, int z, mmask_t bmask)
{
+ vs_widget_ref tmpref(this);
+
if(bmask & (BUTTON1_CLICKED | BUTTON2_CLICKED |
BUTTON3_CLICKED | BUTTON4_CLICKED |
BUTTON1_RELEASED | BUTTON2_RELEASED |
@@ -121,6 +125,8 @@
bool vs_button::handle_key(const key &k)
{
+ vs_widget_ref tmpref(this);
+
if(global_bindings.key_matches(k, "PushButton") ||
global_bindings.key_matches(k, "Confirm"))
{
Modified: branches/aptitude-0.3/aptitude/src/vscreen/vs_center.cc
==============================================================================
--- branches/aptitude-0.3/aptitude/src/vscreen/vs_center.cc (original)
+++ branches/aptitude-0.3/aptitude/src/vscreen/vs_center.cc Wed Sep 21 17:16:51 2005
@@ -14,6 +14,8 @@
int vs_center::width_request()
{
+ vs_widget_ref tmpref(this);
+
vs_widget_ref subwidget = get_subwidget();
if(subwidget.valid() && subwidget->get_visible())
@@ -24,6 +26,8 @@
int vs_center::height_request(int width)
{
+ vs_widget_ref tmpref(this);
+
vs_widget_ref subwidget = get_subwidget();
if(subwidget.valid() && subwidget->get_visible())
@@ -34,6 +38,8 @@
void vs_center::layout_me()
{
+ vs_widget_ref tmpref(this);
+
vs_widget_ref child=get_subwidget();
if(child.valid())
Modified: branches/aptitude-0.3/aptitude/src/vscreen/vs_container.cc
==============================================================================
--- branches/aptitude-0.3/aptitude/src/vscreen/vs_container.cc (original)
+++ branches/aptitude-0.3/aptitude/src/vscreen/vs_container.cc Wed Sep 21 17:16:51 2005
@@ -1,6 +1,6 @@
// vs_container.cc
//
-// Copyright (C) 2000 Daniel Burrows
+// Copyright (C) 2000, 2005 Daniel Burrows
//
// This program is free software; you can redistribute it and/or
// modify it under the terms of the GNU General Public License as
@@ -26,6 +26,8 @@
void vs_container::add_visible_widget(const vs_widget_ref &w,
bool visible)
{
+ vs_widget_ref tmpref(this);
+
add_widget(w);
if(visible)
Modified: branches/aptitude-0.3/aptitude/src/vscreen/vs_editline.cc
==============================================================================
--- branches/aptitude-0.3/aptitude/src/vscreen/vs_editline.cc (original)
+++ branches/aptitude-0.3/aptitude/src/vscreen/vs_editline.cc Wed Sep 21 17:16:51 2005
@@ -71,6 +71,8 @@
wchar_t vs_editline::get_char(size_t loc)
{
+ vs_widget_ref tmpref(this);
+
if(loc>=prompt.size())
return text[loc-prompt.size()];
else
@@ -79,6 +81,8 @@
void vs_editline::normalize_cursor()
{
+ vs_widget_ref tmpref(this);
+
if(get_width() <= 0)
return;
@@ -153,6 +157,8 @@
point vs_editline::get_cursorloc()
{
+ vs_widget_ref tmpref(this);
+
if(getmaxx()>0)
{
int x=0;
@@ -173,6 +179,8 @@
bool vs_editline::handle_key(const key &k)
{
+ vs_widget_ref tmpref(this);
+
if(bindings->key_matches(k, "DelBack"))
{
if(curloc>0)
@@ -352,6 +360,8 @@
void vs_editline::paint(const style &st)
{
+ vs_widget_ref tmpref(this);
+
int width=getmaxx();
int used=0;
@@ -373,6 +383,8 @@
void vs_editline::dispatch_mouse(short id, int x, int y, int z, mmask_t bstate)
{
+ vs_widget_ref tmpref(this);
+
size_t mouseloc=startloc; // The character at which the mouse press occured
while(mouseloc<prompt.size()+text.size() && x>0)
{
@@ -413,12 +425,16 @@
void vs_editline::add_to_history(std::wstring s)
{
+ vs_widget_ref tmpref(this);
+
if(history)
add_to_history(s, history);
}
void vs_editline::reset_history()
{
+ vs_widget_ref tmpref(this);
+
pre_history_text=L"";
using_history=false;
history_loc=0;
@@ -426,6 +442,8 @@
void vs_editline::set_text(wstring _text)
{
+ vs_widget_ref tmpref(this);
+
text=_text;
if(curloc>text.size())
curloc=text.size();
@@ -435,6 +453,8 @@
void vs_editline::set_text(string _text)
{
+ vs_widget_ref tmpref(this);
+
wstring wtext;
if(transcode(_text, wtext))
set_text(wtext);
@@ -452,6 +472,8 @@
int vs_editline::width_request()
{
+ vs_widget_ref tmpref(this);
+
if(desired_size == -1)
return wcswidth(prompt.c_str(), prompt.size())+wcswidth(text.c_str(), text.size());
else
Modified: branches/aptitude-0.3/aptitude/src/vscreen/vs_frame.cc
==============================================================================
--- branches/aptitude-0.3/aptitude/src/vscreen/vs_frame.cc (original)
+++ branches/aptitude-0.3/aptitude/src/vscreen/vs_frame.cc Wed Sep 21 17:16:51 2005
@@ -16,6 +16,8 @@
int vs_frame::width_request()
{
+ vs_widget_ref tmpref(this);
+
vs_widget_ref subwidget = get_subwidget();
if(subwidget.valid() && subwidget->get_visible())
@@ -26,6 +28,8 @@
int vs_frame::height_request(int width)
{
+ vs_widget_ref tmpref(this);
+
if(width<2)
return 0;
else
@@ -41,6 +45,8 @@
void vs_frame::layout_me()
{
+ vs_widget_ref tmpref(this);
+
vs_widget_ref subwidget = get_subwidget();
if(subwidget.valid())
@@ -54,6 +60,8 @@
void vs_frame::paint(const style &st)
{
+ vs_widget_ref tmpref(this);
+
border(0,0,0,0,0,0,0,0);
vs_widget_ref subwidget = get_subwidget();
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 17:16:51 2005
@@ -82,8 +82,8 @@
void vs_label::set_text(const string &_txt)
{
set_text(text_fragment(_txt));
-
}
+
void vs_label::set_text(const wstring &_txt, const style &st)
{
set_text(text_fragment(_txt));
Modified: branches/aptitude-0.3/aptitude/src/vscreen/vs_menu.cc
==============================================================================
--- branches/aptitude-0.3/aptitude/src/vscreen/vs_menu.cc (original)
+++ branches/aptitude-0.3/aptitude/src/vscreen/vs_menu.cc Wed Sep 21 17:16:51 2005
@@ -127,6 +127,8 @@
void vs_menu::append_item(vs_menu_item *newitem)
{
+ vs_widget_ref tmpref(this);
+
items.push_back(newitem);
if(get_visible())
@@ -138,6 +140,8 @@
void vs_menu::remove_item(vs_menu_item *item)
{
+ vs_widget_ref tmpref(this);
+
itemlist::size_type idx=0;
while(idx<items.size() && items[idx]!=item)
@@ -163,6 +167,8 @@
{
int req_width=min_width;
+ vs_widget_ref tmpref(this);
+
for(itemlist::const_iterator item=items.begin();
item!=items.end(); ++item)
if(*item)
@@ -196,6 +202,8 @@
void vs_menu::highlight_current()
{
+ vs_widget_ref tmpref(this);
+
if(cursorloc>=0 && cursorloc<items.size())
item_highlighted(items[cursorloc]);
else
@@ -204,6 +212,8 @@
void vs_menu::set_cursor(itemlist::size_type pos)
{
+ vs_widget_ref tmpref(this);
+
if(cursorloc!=pos)
{
cursorloc=pos;
@@ -216,6 +226,8 @@
void vs_menu::appear()
{
+ vs_widget_ref tmpref(this);
+
cursorloc=next_selectable(0);
highlight_current();
@@ -223,6 +235,8 @@
void vs_menu::disappear()
{
+ vs_widget_ref tmpref(this);
+
set_cursor(items.size());
}
@@ -233,11 +247,15 @@
bool vs_menu::selectable(itemlist::size_type pos)
{
+ vs_widget_ref tmpref(this);
+
return pos>=0 && pos<items.size() && items[pos] && items[pos]->is_enabled();
}
vs_menu::itemlist::size_type vs_menu::next_selectable(itemlist::size_type pos)
{
+ vs_widget_ref tmpref(this);
+
if(pos<0 || pos>=items.size())
pos=0;
@@ -250,6 +268,8 @@
vs_menu::itemlist::size_type vs_menu::prev_selectable(itemlist::size_type pos)
{
+ vs_widget_ref tmpref(this);
+
if(pos<0 || pos>=items.size())
pos=items.size()-1;
@@ -265,6 +285,8 @@
void vs_menu::sanitize_cursor(bool forward)
{
+ vs_widget_ref tmpref(this);
+
if(forward)
// Double-invoking next_selectable will search from the
// start of the menu if searching forwards fails.
@@ -277,6 +299,8 @@
bool vs_menu::handle_key(const key &k)
{
+ vs_widget_ref tmpref(this);
+
// This will ensure that the cursor is in bounds if possible, and that
// if it is in bounds, a "real" item is selected.
sanitize_cursor(true);
@@ -340,6 +364,8 @@
void vs_menu::dispatch_mouse(short id, int x, int y, int z, mmask_t bmask)
{
+ vs_widget_ref tmpref(this);
+
if(bmask & (BUTTON1_RELEASED | BUTTON2_RELEASED |
BUTTON3_RELEASED | BUTTON4_RELEASED |
BUTTON1_CLICKED | BUTTON2_CLICKED |
@@ -369,6 +395,8 @@
// GTK+, and text screens have even less space to play with..
void vs_menu::paint(const style &st)
{
+ vs_widget_ref tmpref(this);
+
int width, height;
const style border_style=st+get_style("MenuBorder");
const style highlighted_style=st+get_style("HighlightedMenuEntry");
@@ -500,6 +528,8 @@
bool vs_menu::get_cursorvisible()
{
+ vs_widget_ref tmpref(this);
+
sanitize_cursor(true);
return cursorloc>=0 && cursorloc<items.size();
@@ -507,6 +537,8 @@
point vs_menu::get_cursorloc()
{
+ vs_widget_ref tmpref(this);
+
sanitize_cursor(true);
return point(0, 1+cursorloc);
Modified: branches/aptitude-0.3/aptitude/src/vscreen/vs_menubar.cc
==============================================================================
--- branches/aptitude-0.3/aptitude/src/vscreen/vs_menubar.cc (original)
+++ branches/aptitude-0.3/aptitude/src/vscreen/vs_menubar.cc Wed Sep 21 17:16:51 2005
@@ -32,6 +32,8 @@
void vs_menubar::destroy()
{
+ vs_widget_ref tmpref(this);
+
if(subwidget.valid())
subwidget->destroy();
assert(!subwidget.valid());
@@ -53,6 +55,8 @@
void vs_menubar::got_focus()
{
+ vs_widget_ref tmpref(this);
+
vs_widget_ref w=get_focus();
if(w.valid())
w->focussed();
@@ -60,6 +64,8 @@
void vs_menubar::lost_focus()
{
+ vs_widget_ref tmpref(this);
+
vs_widget_ref w=get_focus();
if(w.valid())
w->unfocussed();
@@ -130,6 +136,8 @@
void vs_menubar::append_item(const wstring &title,
const vs_menu_ref &menu)
{
+ vs_widget_ref tmpref(this);
+
items.push_back(item(L' '+title+L' ', menu));
menu->shown_sig.connect(sigc::bind(sigc::mem_fun(*this, &vs_menubar::show_menu_bare), menu.weak_ref()));
@@ -142,6 +150,8 @@
void vs_menubar::set_subwidget(const vs_widget_ref &w)
{
+ vs_widget_ref tmpref(this);
+
if(subwidget.valid())
{
subwidget->set_owner(NULL);
@@ -161,12 +171,16 @@
void vs_menubar::show_all()
{
+ vs_widget_ref tmpref(this);
+
if(subwidget.valid())
subwidget->show_all();
}
void vs_menubar::add_widget(const vs_widget_ref &w)
{
+ vs_widget_ref tmpref(this);
+
assert(!subwidget.valid());
set_subwidget(w);
@@ -174,6 +188,8 @@
void vs_menubar::rem_widget(const vs_widget_ref &w)
{
+ vs_widget_ref tmpref(this);
+
if(w == subwidget)
set_subwidget(NULL);
else
@@ -207,6 +223,8 @@
int vs_menubar::width_request()
{
+ vs_widget_ref tmpref(this);
+
int w=0;
// Calculate the size of the bar itself.
@@ -250,6 +268,8 @@
// or wrap to the next line?
int vs_menubar::height_request(int w)
{
+ vs_widget_ref tmpref(this);
+
int h=always_visible?1:0;
for(activemenulist::iterator i=active_menus.begin(), num=0;
@@ -272,6 +292,8 @@
void vs_menubar::layout_me()
{
+ vs_widget_ref tmpref(this);
+
// Find the starting X location of each active menu.
for(activemenulist::iterator i=active_menus.begin();
i!=active_menus.end();
@@ -321,6 +343,8 @@
void vs_menubar::show_menu(const vs_menu_ref &w)
{
+ vs_widget_ref tmpref(this);
+
if(active)
{
vs_widget_ref old_focus=get_focus();
@@ -344,6 +368,8 @@
void vs_menubar::hide_menu(const vs_menu_ref &w)
{
+ vs_widget_ref tmpref(this);
+
if(active)
{
for(activemenulist::iterator i=active_menus.begin();
@@ -381,6 +407,8 @@
void vs_menubar::appear()
{
+ vs_widget_ref tmpref(this);
+
if(!active)
{
active=true;
@@ -398,6 +426,8 @@
void vs_menubar::disappear()
{
+ vs_widget_ref tmpref(this);
+
if(active)
{
while(!active_menus.empty())
@@ -415,6 +445,8 @@
bool vs_menubar::handle_key(const key &k)
{
+ vs_widget_ref tmpref(this);
+
if(bindings->key_matches(k, "ToggleMenuActive"))
{
if(active)
@@ -524,6 +556,8 @@
void vs_menubar::paint(const style &st)
{
+ vs_widget_ref tmpref(this);
+
if(subwidget.valid())
subwidget->display(st);
@@ -570,6 +604,8 @@
void vs_menubar::dispatch_mouse(short id, int x, int y, int z, mmask_t bmask)
{
+ vs_widget_ref tmpref(this);
+
if(y==0)
{
if(bmask & (BUTTON1_CLICKED | BUTTON2_CLICKED |
Modified: branches/aptitude-0.3/aptitude/src/vscreen/vs_minibuf_win.cc
==============================================================================
--- branches/aptitude-0.3/aptitude/src/vscreen/vs_minibuf_win.cc (original)
+++ branches/aptitude-0.3/aptitude/src/vscreen/vs_minibuf_win.cc Wed Sep 21 17:16:51 2005
@@ -51,6 +51,8 @@
void vs_minibuf_win::destroy()
{
+ vs_widget_ref tmpref(this);
+
if(main_widget.valid())
main_widget->destroy();
assert(!main_widget.valid());
@@ -66,6 +68,8 @@
void vs_minibuf_win::set_main_widget(const vs_widget_ref &w)
{
+ vs_widget_ref tmpref(this);
+
defocus();
if(main_widget.valid())
@@ -89,6 +93,8 @@
int vs_minibuf_win::width_request()
{
+ vs_widget_ref tmpref(this);
+
int w=0;
if(status.valid())
@@ -105,6 +111,8 @@
int vs_minibuf_win::height_request(int w)
{
+ vs_widget_ref tmpref(this);
+
int h=2;
if(main_widget.valid())
@@ -114,6 +122,8 @@
void vs_minibuf_win::layout_me()
{
+ vs_widget_ref tmpref(this);
+
if(header.valid())
header->alloc_size(0, 0, getmaxx(), 1);
@@ -129,6 +139,8 @@
void vs_minibuf_win::paint(const style &st)
{
+ vs_widget_ref tmpref(this);
+
if(main_widget.valid() && main_widget->get_visible())
main_widget->display(st);
@@ -140,16 +152,22 @@
void vs_minibuf_win::set_header(string new_header)
{
+ vs_widget_ref tmpref(this);
+
header->set_text(new_header);
}
void vs_minibuf_win::set_status(string new_status)
{
+ vs_widget_ref tmpref(this);
+
status_lbl->set_text(new_status);
}
void vs_minibuf_win::add_widget(const vs_widget_ref &widget)
{
+ vs_widget_ref tmpref(this);
+
defocus();
status->add_widget(widget);
refocus();
@@ -157,6 +175,8 @@
void vs_minibuf_win::rem_widget(const vs_widget_ref &widget)
{
+ vs_widget_ref tmpref(this);
+
assert(widget.valid());
if(widget == header)
@@ -184,6 +204,8 @@
void vs_minibuf_win::show_all()
{
+ vs_widget_ref tmpref(this);
+
if(main_widget.valid())
main_widget->show_all();
status->show();
@@ -192,6 +214,8 @@
vs_widget_ref vs_minibuf_win::get_focus()
{
+ vs_widget_ref tmpref(this);
+
if(status.valid() && status->focus_me())
return status;
else if(main_widget.valid() && main_widget->get_visible() && main_widget->focus_me())
Modified: branches/aptitude-0.3/aptitude/src/vscreen/vs_multiplex.cc
==============================================================================
--- branches/aptitude-0.3/aptitude/src/vscreen/vs_multiplex.cc (original)
+++ branches/aptitude-0.3/aptitude/src/vscreen/vs_multiplex.cc Wed Sep 21 17:16:51 2005
@@ -45,6 +45,8 @@
void vs_multiplex::destroy()
{
+ vs_widget_ref tmpref(this);
+
while(!children.empty())
children.front().w->destroy();
@@ -74,6 +76,8 @@
int vs_multiplex::width_request()
{
+ vs_widget_ref tmpref(this);
+
int rval=0;
for(list<child_info>::iterator i=children.begin();
@@ -86,6 +90,8 @@
int vs_multiplex::height_request(int width)
{
+ vs_widget_ref tmpref(this);
+
int rval=0;
for(list<child_info>::iterator i=children.begin();
@@ -102,6 +108,8 @@
void vs_multiplex::layout_me()
{
+ vs_widget_ref tmpref(this);
+
if(visible_child!=children.end())
{
if(tabs_visible())
@@ -113,6 +121,8 @@
void vs_multiplex::paint(const style &st)
{
+ vs_widget_ref tmpref(this);
+
if(tabs_visible())
{
int visible_children=0;
@@ -181,6 +191,8 @@
void vs_multiplex::dispatch_mouse(short id, int x, int y, int z,
mmask_t bstate)
{
+ vs_widget_ref tmpref(this);
+
if(tabs_visible() && y == 0)
{
// FIXME: duplicated code from above, is there a good way to
@@ -227,18 +239,24 @@
void vs_multiplex::got_focus()
{
+ vs_widget_ref tmpref(this);
+
if(visible_child!=children.end())
visible_child->w->focussed();
}
void vs_multiplex::lost_focus()
{
+ vs_widget_ref tmpref(this);
+
if(visible_child!=children.end())
visible_child->w->unfocussed();
}
void vs_multiplex::show_all()
{
+ vs_widget_ref tmpref(this);
+
show();
if(visible_child!=children.end())
@@ -247,6 +265,8 @@
void vs_multiplex::show_widget(const vs_widget_ref &w)
{
+ vs_widget_ref tmpref(this);
+
assert(!children.empty());
list<child_info>::iterator new_visible=visible_child;
@@ -285,6 +305,8 @@
void vs_multiplex::hide_widget(const vs_widget_ref &w)
{
+ vs_widget_ref tmpref(this);
+
assert(!children.empty());
if(visible_child!=children.end() && visible_child->w==w)
@@ -353,6 +375,8 @@
void vs_multiplex::rem_widget(const vs_widget_ref &w)
{
+ vs_widget_ref tmpref(this);
+
hide_widget(w);
for(list<child_info>::iterator i=children.begin(); i!=children.end(); i++)
@@ -386,6 +410,8 @@
void vs_multiplex::add_widget(const vs_widget_ref &w,
const wstring &title)
{
+ vs_widget_ref tmpref(this);
+
w->shown_sig.connect(sigc::bind(sigc::mem_fun(*this, &vs_multiplex::show_widget_bare), w.weak_ref()));
w->hidden_sig.connect(sigc::bind(sigc::mem_fun(*this, &vs_multiplex::hide_widget_bare), w.weak_ref()));
@@ -405,6 +431,8 @@
const vs_widget_ref &after,
const wstring &title)
{
+ vs_widget_ref tmpref(this);
+
for(list<child_info>::iterator i=children.begin();
i!=children.end();
i++)
@@ -438,6 +466,8 @@
void vs_multiplex::cycle_forward()
{
+ vs_widget_ref tmpref(this);
+
if(!children.empty())
{
list<child_info>::iterator new_visible=visible_child;
@@ -479,6 +509,8 @@
void vs_multiplex::cycle_backward()
{
+ vs_widget_ref tmpref(this);
+
if(!children.empty())
{
list<child_info>::iterator new_visible=visible_child;
Modified: branches/aptitude-0.3/aptitude/src/vscreen/vs_pager.cc
==============================================================================
--- branches/aptitude-0.3/aptitude/src/vscreen/vs_pager.cc (original)
+++ branches/aptitude-0.3/aptitude/src/vscreen/vs_pager.cc Wed Sep 21 17:16:51 2005
@@ -65,6 +65,8 @@
void vs_pager::set_text(const wstring &s)
{
+ vs_widget_ref tmpref(this);
+
wstring::size_type loc=0;
text_width=0;
@@ -111,18 +113,24 @@
void vs_pager::do_line_signal()
{
+ vs_widget_ref tmpref(this);
+
int realmax=max<int>(lines.size()-getmaxy(), 0);
line_changed(first_line, realmax);
}
void vs_pager::do_column_signal()
{
+ vs_widget_ref tmpref(this);
+
int realmax=max<int>(text_width-getmaxx(), 0);
column_changed(first_column, realmax);
}
void vs_pager::scroll_up(line_count nlines)
{
+ vs_widget_ref tmpref(this);
+
if(first_line<nlines)
first_line=0;
else
@@ -134,6 +142,8 @@
void vs_pager::scroll_down(line_count nlines)
{
+ vs_widget_ref tmpref(this);
+
first_line=min(first_line+nlines, lines.size()-getmaxy());
do_line_signal();
@@ -142,6 +152,8 @@
void vs_pager::scroll_left(col_count ncols)
{
+ vs_widget_ref tmpref(this);
+
if(first_column<ncols)
first_column=0;
else
@@ -153,6 +165,8 @@
void vs_pager::scroll_right(col_count ncols)
{
+ vs_widget_ref tmpref(this);
+
first_column=min(first_column+ncols, text_width-getmaxx());
do_column_signal();
@@ -161,6 +175,8 @@
void vs_pager::scroll_top()
{
+ vs_widget_ref tmpref(this);
+
first_line=0;
do_line_signal();
@@ -169,6 +185,8 @@
void vs_pager::scroll_bottom()
{
+ vs_widget_ref tmpref(this);
+
first_line=lines.size()-getmaxy();
do_line_signal();
@@ -177,6 +195,8 @@
void vs_pager::scroll_page(bool dir)
{
+ vs_widget_ref tmpref(this);
+
if(dir)
scroll_up(getmaxy());
else
@@ -185,6 +205,8 @@
void vs_pager::search_for(const wstring &s)
{
+ vs_widget_ref tmpref(this);
+
if(s!=L"")
last_search=s;
else if(last_search==L"")
@@ -234,6 +256,8 @@
bool vs_pager::handle_key(const key &k)
{
+ vs_widget_ref tmpref(this);
+
if(bindings->key_matches(k, "Up"))
scroll_up(1);
else if(bindings->key_matches(k, "Down"))
@@ -259,12 +283,16 @@
// Could find out what dimensions changed and only update along those?
void vs_pager::layout_me()
{
+ vs_widget_ref tmpref(this);
+
do_line_signal();
do_column_signal();
}
void vs_pager::paint(const style &st)
{
+ vs_widget_ref tmpref(this);
+
int width,height;
getmaxyx(height, width);
@@ -340,6 +368,8 @@
void vs_file_pager::load_file(const string &filename,
const char *encoding)
{
+ vs_widget_ref tmpref(this);
+
int fd=open(filename.c_str(), O_RDONLY, 0644);
if(fd==-1)
@@ -385,6 +415,8 @@
void vs_file_pager::load_file(const wstring &filename,
const char *encoding)
{
+ vs_widget_ref tmpref(this);
+
string mbfilename;
if(transcode(filename, mbfilename))
Modified: branches/aptitude-0.3/aptitude/src/vscreen/vs_passthrough.cc
==============================================================================
--- branches/aptitude-0.3/aptitude/src/vscreen/vs_passthrough.cc (original)
+++ branches/aptitude-0.3/aptitude/src/vscreen/vs_passthrough.cc Wed Sep 21 17:16:51 2005
@@ -22,6 +22,8 @@
void vs_passthrough::gained_focus()
{
+ vs_widget_ref tmpref(this);
+
vs_widget_ref w = get_focus();
if(w.valid())
@@ -30,6 +32,8 @@
void vs_passthrough::lost_focus()
{
+ vs_widget_ref tmpref(this);
+
vs_widget_ref w = get_focus();
if(w.valid())
@@ -38,6 +42,8 @@
bool vs_passthrough::focus_me()
{
+ vs_widget_ref tmpref(this);
+
vs_widget_ref w = get_focus();
if(w.valid() && w->focus_me())
@@ -48,6 +54,8 @@
bool vs_passthrough::get_cursorvisible()
{
+ vs_widget_ref tmpref(this);
+
vs_widget_ref w = get_focus();
return w.valid() && w->get_cursorvisible();
@@ -55,6 +63,8 @@
point vs_passthrough::get_cursorloc()
{
+ vs_widget_ref tmpref(this);
+
vs_widget_ref w = get_focus();
if(w.valid())
@@ -71,6 +81,8 @@
bool vs_passthrough::handle_key(const key &k)
{
+ vs_widget_ref tmpref(this);
+
vs_widget_ref w = get_focus();
if(w.valid() && w->get_visible() && w->focus_me())
@@ -82,6 +94,8 @@
void vs_passthrough::dispatch_mouse(short id, int x, int y, int z,
mmask_t bstate)
{
+ vs_widget_ref tmpref(this);
+
vs_widget_ref w = get_focus();
if(w.valid() && w->get_visible())
Modified: branches/aptitude-0.3/aptitude/src/vscreen/vs_scrollbar.cc
==============================================================================
--- branches/aptitude-0.3/aptitude/src/vscreen/vs_scrollbar.cc (original)
+++ branches/aptitude-0.3/aptitude/src/vscreen/vs_scrollbar.cc Wed Sep 21 17:16:51 2005
@@ -6,12 +6,16 @@
int vs_scrollbar::get_slider()
{
+ vs_widget_ref tmpref(this);
+
int width = dir==HORIZONTAL?getmaxx():getmaxy();
return max==0?-1:(width-1)*val/max;
}
void vs_scrollbar::paint(const style &st)
{
+ vs_widget_ref tmpref(this);
+
if(dir==HORIZONTAL)
{
int width=getmaxx();
@@ -71,6 +75,8 @@
int x, int y, int z,
mmask_t bstate)
{
+ vs_widget_ref tmpref(this);
+
int slider_loc=get_slider();
int mloc = dir==HORIZONTAL?x:y;
Modified: branches/aptitude-0.3/aptitude/src/vscreen/vs_size_box.cc
==============================================================================
--- branches/aptitude-0.3/aptitude/src/vscreen/vs_size_box.cc (original)
+++ branches/aptitude-0.3/aptitude/src/vscreen/vs_size_box.cc Wed Sep 21 17:16:51 2005
@@ -20,6 +20,8 @@
int vs_size_box::width_request()
{
+ vs_widget_ref tmpref(this);
+
vs_widget_ref child = get_subwidget();
if(child.valid())
@@ -30,6 +32,8 @@
int vs_size_box::height_request(int w)
{
+ vs_widget_ref tmpref(this);
+
vs_widget_ref child = get_subwidget();
if(child.valid())
@@ -40,6 +44,8 @@
void vs_size_box::layout_me()
{
+ vs_widget_ref tmpref(this);
+
vs_widget_ref child = get_subwidget();
if(child.valid())
Modified: branches/aptitude-0.3/aptitude/src/vscreen/vs_stacked.cc
==============================================================================
--- branches/aptitude-0.3/aptitude/src/vscreen/vs_stacked.cc (original)
+++ branches/aptitude-0.3/aptitude/src/vscreen/vs_stacked.cc Wed Sep 21 17:16:51 2005
@@ -19,6 +19,8 @@
void vs_stacked::destroy()
{
+ vs_widget_ref tmpref(this);
+
while(!children.empty())
children.front().w->destroy();
@@ -27,6 +29,8 @@
void vs_stacked::add_widget(const vs_widget_ref &w)
{
+ vs_widget_ref tmpref(this);
+
sigc::connection shown_conn=w->shown_sig.connect(sigc::bind(sigc::mem_fun(*this, &vs_stacked::raise_widget_bare), w.weak_ref()));
sigc::connection hidden_conn=w->hidden_sig.connect(sigc::mem_fun(*this, &vs_stacked::hide_widget));
@@ -49,6 +53,8 @@
void vs_stacked::rem_widget(const vs_widget_ref &wBare)
{
+ vs_widget_ref tmpref(this);
+
vs_widget_ref w(wBare);
for(childlist::iterator i=children.begin();
@@ -75,6 +81,8 @@
void vs_stacked::raise_widget(const vs_widget_ref &w)
{
+ vs_widget_ref tmpref(this);
+
for(childlist::iterator i=children.begin();
i!=children.end();
i++)
@@ -94,6 +102,8 @@
void vs_stacked::lower_widget(const vs_widget_ref &w)
{
+ vs_widget_ref tmpref(this);
+
for(childlist::iterator i=children.begin();
i!=children.end();
i++)
@@ -113,6 +123,8 @@
void vs_stacked::paint(const style &st)
{
+ vs_widget_ref tmpref(this);
+
// Go through the children back-to-front (reverse order)
for(childlist::reverse_iterator i=children.rbegin();
i!=children.rend();
@@ -123,6 +135,8 @@
void vs_stacked::dispatch_mouse(short id, int x, int y, int z, mmask_t bstate)
{
+ vs_widget_ref tmpref(this);
+
for(childlist::iterator i=children.begin();
i!=children.end();
++i)
@@ -136,6 +150,8 @@
vs_widget_ref vs_stacked::get_focus()
{
+ vs_widget_ref tmpref(this);
+
for(childlist::iterator i=children.begin();
i!=children.end();
i++)
@@ -149,6 +165,8 @@
void vs_stacked::show_all()
{
+ vs_widget_ref tmpref(this);
+
defocus();
for(childlist::iterator i=children.begin();
@@ -177,6 +195,8 @@
void vs_stacked::layout_me()
{
+ vs_widget_ref tmpref(this);
+
for(childlist::iterator i=children.begin(); i!=children.end(); i++)
i->w->alloc_size(0, 0, getmaxx(), getmaxy());
}
Modified: branches/aptitude-0.3/aptitude/src/vscreen/vs_statuschoice.cc
==============================================================================
--- branches/aptitude-0.3/aptitude/src/vscreen/vs_statuschoice.cc (original)
+++ branches/aptitude-0.3/aptitude/src/vscreen/vs_statuschoice.cc Wed Sep 21 17:16:51 2005
@@ -29,6 +29,8 @@
bool vs_statuschoice::handle_key(const key &k)
{
+ vs_widget_ref tmpref(this);
+
if(bindings->key_matches(k, "Confirm"))
{
chosen(0);
Modified: branches/aptitude-0.3/aptitude/src/vscreen/vs_table.cc
==============================================================================
--- branches/aptitude-0.3/aptitude/src/vscreen/vs_table.cc (original)
+++ branches/aptitude-0.3/aptitude/src/vscreen/vs_table.cc Wed Sep 21 17:16:51 2005
@@ -66,6 +66,8 @@
void vs_table::destroy()
{
+ vs_widget_ref tmpref(this);
+
while(!children.empty())
children.front().w->destroy();
@@ -74,6 +76,8 @@
void vs_table::set_rowsep(int n)
{
+ vs_widget_ref tmpref(this);
+
if(n!=rowsep)
{
rowsep=n;
@@ -84,6 +88,8 @@
void vs_table::set_colsep(int n)
{
+ vs_widget_ref tmpref(this);
+
if(n!=colsep)
{
colsep=n;
@@ -103,6 +109,8 @@
void vs_table::lost_focus()
{
+ vs_widget_ref tmpref(this);
+
vs_widget_ref w=get_focus();
if(w.valid())
@@ -111,12 +119,16 @@
void vs_table::add_widget_bare(vscreen_widget &w, int row_start, int col_start, int row_span, int col_span, bool expand, bool shrink)
{
+ vs_widget_ref tmpref(this);
+
add_widget(vs_widget_ref(&w), row_start, col_start,
row_span, col_span, expand, shrink);
}
void vs_table::add_widget(const vs_widget_ref &w, int row_start, int col_start, int row_span, int col_span, bool expand, bool shrink)
{
+ vs_widget_ref tmpref(this);
+
int opts=ALIGN_CENTER;
if(expand)
opts|=EXPAND|FILL;
@@ -128,12 +140,16 @@
void vs_table::add_widget_opts_bare(vscreen_widget &w, int row_start, int col_start, int row_span, int col_span, int xopts, int yopts)
{
+ vs_widget_ref tmpref(this);
+
add_widget_opts(vs_widget_ref(&w), row_start, col_start,
row_span, col_span, xopts, yopts);
}
void vs_table::add_widget_opts(const vs_widget_ref &w, int row_start, int col_start, int row_span, int col_span, int xopts, int yopts)
{
+ vs_widget_ref tmpref(this);
+
// sanity check
for(childlist::iterator i=children.begin(); i!=children.end(); ++i)
if(i->w==w)
@@ -164,11 +180,15 @@
void vs_table::hide_widget_bare(vscreen_widget &w)
{
+ vs_widget_ref tmpref(this);
+
hide_widget(vs_widget_ref(&w));
}
void vs_table::hide_widget(const vs_widget_ref &w)
{
+ vs_widget_ref tmpref(this);
+
if(focus!=children.end() && w==focus->w)
{
if(get_isfocussed())
@@ -198,11 +218,15 @@
void vs_table::show_widget_bare(vscreen_widget &w)
{
+ vs_widget_ref tmpref(this);
+
show_widget(vs_widget_ref(&w));
}
void vs_table::show_widget(const vs_widget_ref &w)
{
+ vs_widget_ref tmpref(this);
+
if(w->focus_me() && focus==children.end())
{
for(childlist::iterator i=children.begin(); i!=children.end(); ++i)
@@ -220,11 +244,15 @@
void vs_table::add_widget(const vs_widget_ref &w)
{
+ vs_widget_ref tmpref(this);
+
add_widget(w, num_rows, 0, 1);
}
void vs_table::calc_dimensions()
{
+ vs_widget_ref tmpref(this);
+
num_rows=0;
num_cols=0;
@@ -240,6 +268,8 @@
void vs_table::rem_widget(const vs_widget_ref &wBare)
{
+ vs_widget_ref tmpref(this);
+
vs_widget_ref w = wBare;
for(childlist::iterator i = children.begin(); i != children.end(); ++i)
@@ -294,6 +324,8 @@
void vs_table::focus_widget(const vs_widget_ref &w)
{
+ vs_widget_ref tmpref(this);
+
for(childlist::iterator i=children.begin(); i!=children.end(); ++i)
if(i->w==w)
{
@@ -322,6 +354,8 @@
vs_widget_ref vs_table::get_focus()
{
+ vs_widget_ref tmpref(this);
+
if(focus!=children.end() && focus->w->get_visible() &&
focus->w->focus_me())
return focus->w;
@@ -345,6 +379,8 @@
void vs_table::show_all()
{
+ vs_widget_ref tmpref(this);
+
for(childlist::iterator i=children.begin(); i!=children.end(); ++i)
i->w->show_all();
@@ -524,6 +560,8 @@
bool vs_table::handle_key(const key &k)
{
+ vs_widget_ref tmpref(this);
+
if(focus!=children.end())
{
vs_widget_ref w = focus->w;
@@ -668,6 +706,8 @@
*/
void vs_table::alloc_ideal_widths(vector<int> &col_sizes)
{
+ vs_widget_ref tmpref(this);
+
vector<bool> col_expandable(num_cols, false);
vector<child_info *> sorted_children;
@@ -776,6 +816,8 @@
*/
void vs_table::expand_widths(vector<int> &col_sizes, int target_w)
{
+ vs_widget_ref tmpref(this);
+
int current_width=accumulate(col_sizes.begin(), col_sizes.end(), 0);
int shortfall=target_w-current_width;
@@ -861,6 +903,8 @@
*/
void vs_table::shrink_widths(vector<int> &col_sizes, int target_w)
{
+ vs_widget_ref tmpref(this);
+
vector<bool> col_shrinkable(num_cols, false);
int n_shrinkable=0;
int current_width=accumulate(col_sizes.begin(), col_sizes.end(), 0);
@@ -956,6 +1000,8 @@
void vs_table::alloc_ideal_heights(vector<int> &row_sizes,
const vector<int> &col_sizes)
{
+ vs_widget_ref tmpref(this);
+
vector<bool> row_expandable(num_rows, false);
vector<child_info *> sorted_children;
@@ -1069,6 +1115,8 @@
*/
void vs_table::expand_heights(vector<int> &row_sizes, int target_h)
{
+ vs_widget_ref tmpref(this);
+
int current_height=accumulate(row_sizes.begin(), row_sizes.end(), 0);
int shortfall=target_h-current_height;
@@ -1154,6 +1202,8 @@
*/
void vs_table::shrink_heights(vector<int> &row_sizes, int target_h)
{
+ vs_widget_ref tmpref(this);
+
vector<bool> row_shrinkable(num_rows, false);
int n_shrinkable=0;
int current_height=accumulate(row_sizes.begin(), row_sizes.end(), 0);
@@ -1249,6 +1299,8 @@
void vs_table::alloc_child_sizes(const vector<int> &col_sizes,
const vector<int> &row_sizes)
{
+ vs_widget_ref tmpref(this);
+
vector<int> col_starts(num_cols), row_starts(num_rows);
// partial_sum almost works...but not quite.
@@ -1312,6 +1364,8 @@
// Returns the sum of the ideal column widths; doesn't save anything.
int vs_table::width_request()
{
+ vs_widget_ref tmpref(this);
+
vector<int> col_sizes(num_cols);
alloc_ideal_widths(col_sizes);
@@ -1323,6 +1377,8 @@
// anything.
int vs_table::height_request(int w)
{
+ vs_widget_ref tmpref(this);
+
vector<int> col_sizes(num_cols), row_sizes(num_rows);
alloc_ideal_widths(col_sizes);
@@ -1336,6 +1392,8 @@
void vs_table::layout_me()
{
+ vs_widget_ref tmpref(this);
+
get_focus();
if(get_win())
@@ -1361,6 +1419,8 @@
void vs_table::paint(const style &st)
{
+ vs_widget_ref tmpref(this);
+
for(childlist::iterator i=children.begin(); i!=children.end(); ++i)
if(i->w->get_visible())
i->w->display(st);
@@ -1368,6 +1428,8 @@
void vs_table::dispatch_mouse(short id, int x, int y, int z, mmask_t bstate)
{
+ vs_widget_ref tmpref(this);
+
for(childlist::iterator i=children.begin(); i!=children.end(); ++i)
{
vs_widget_ref w = i->w;
Modified: branches/aptitude-0.3/aptitude/src/vscreen/vscreen_widget.cc
==============================================================================
--- branches/aptitude-0.3/aptitude/src/vscreen/vscreen_widget.cc (original)
+++ branches/aptitude-0.3/aptitude/src/vscreen/vscreen_widget.cc Wed Sep 21 17:16:51 2005
@@ -30,7 +30,7 @@
timeout_value(0),
owner(NULL),
geom(0,0,0,0),
- refcount(0),
+ refcount(1),
visible(false),
isfocussed(false),
pre_display_erase(true),
@@ -64,6 +64,8 @@
void vscreen_widget::set_owner_window(cwindow _win, int x, int y, int w, int h)
{
+ vs_widget_ref tmpref(this);
+
if(_win)
{
geom.x=x;
@@ -150,6 +152,8 @@
void vscreen_widget::show()
{
+ vs_widget_ref tmpref(this);
+
if(is_destroyed)
return;
@@ -160,6 +164,8 @@
void vscreen_widget::show_all()
{
+ vs_widget_ref tmpref(this);
+
if(is_destroyed)
return;
@@ -168,6 +174,8 @@
void vscreen_widget::hide()
{
+ vs_widget_ref tmpref(this);
+
if(is_destroyed)
return;
@@ -178,6 +186,8 @@
void vscreen_widget::display(const style &st)
{
+ vs_widget_ref tmpref(this);
+
if(is_destroyed)
return;
@@ -206,6 +216,8 @@
bool vscreen_widget::handle_key(const key &k)
{
+ vs_widget_ref tmpref(this);
+
if(is_destroyed)
return false;
@@ -225,6 +237,8 @@
bool vscreen_widget::dispatch_key(const key &k)
{
+ vs_widget_ref tmpref(this);
+
if(is_destroyed)
return false;
More information about the Aptitude-svn-commit
mailing list