diff options
author | Daniel Burrows <dburrows@debian.org> | 2010-04-19 22:01:27 -0700 |
---|---|---|
committer | Daniel Burrows <dburrows@debian.org> | 2010-04-19 22:01:27 -0700 |
commit | de45de01a81e0f9d6559f706cef482e5fc2eb8d2 (patch) | |
tree | 596d4a4467ddbfddd2937ceab24614720e28d415 /src/generic/problemresolver/incremental_expression.cc | |
parent | 50a28dbe7bf116aba0ff13dfd2cbe972b7df2d09 (diff) | |
download | aptitude-de45de01a81e0f9d6559f706cef482e5fc2eb8d2.tar.gz |
Uniformly treat NULL pointers to incremental expressions as incremental expressions that are always "true".
I considered trying to optimize by stripping NULLs out of "and" and
"or" expressions, but that seems a bit tricky. It might be more
straightforward if I introduce "true" and "false" expressions
explicitly, though (part of the trouble is that it's probably bad if
creation routines return NULL, and they can't currently return false).
Diffstat (limited to 'src/generic/problemresolver/incremental_expression.cc')
-rw-r--r-- | src/generic/problemresolver/incremental_expression.cc | 14 |
1 files changed, 9 insertions, 5 deletions
diff --git a/src/generic/problemresolver/incremental_expression.cc b/src/generic/problemresolver/incremental_expression.cc index 8f5c1547..7285cefc 100644 --- a/src/generic/problemresolver/incremental_expression.cc +++ b/src/generic/problemresolver/incremental_expression.cc @@ -1,7 +1,7 @@ /** \file incremental_expression.cc */ // -*-c++-*- -// Copyright (C) 2009 Daniel Burrows +// Copyright (C) 2009-2010 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 @@ -27,7 +27,7 @@ void counting_bool_e::init_num_true() num_true = 0; for(std::vector<cwidget::util::ref_ptr<expression<bool> > >::const_iterator it = children.begin(); it != children.end(); ++it) - if((*it)->get_value()) + if(!it->valid() || (*it)->get_value()) ++num_true; } @@ -53,7 +53,7 @@ void counting_bool_e::child_modified(const cwidget::util::ref_ptr<expression<boo void counting_bool_e::add_child(const cwidget::util::ref_ptr<expression<bool> > &child) { - if(child->get_value()) + if(!child.valid() || child->get_value()) { bool old_value = get_value(); @@ -71,7 +71,7 @@ void counting_bool_e::add_child(const cwidget::util::ref_ptr<expression<bool> > void counting_bool_e::remove_child(const cwidget::util::ref_ptr<expression<bool> > &child) { - if(child->get_value()) + if(!child.valid() || child->get_value()) { bool old_value = get_value(); @@ -116,7 +116,11 @@ void not_e::child_modified(const cwidget::util::ref_ptr<expression<bool> > &chil bool not_e::get_value() { - return !get_child()->get_value(); + if(get_child().valid()) + return !get_child()->get_value(); + else + // NULL pointers count as "true". + return false; } void not_e::dump(std::ostream &out) |