diff --git a/src/proc/control/command-argument-holder.hpp b/src/proc/control/command-argument-holder.hpp index c18e18b06..3cc41c539 100644 --- a/src/proc/control/command-argument-holder.hpp +++ b/src/proc/control/command-argument-holder.hpp @@ -187,7 +187,10 @@ namespace control { : arguments_() , memento_() { - arguments_.template create (*oAh.arguments_); + if (oAh.arguments_->isValid()) // don't clone garbage from invalid arguments + arguments_.template create (*oAh.arguments_); + + // memento can be cloned as-is, irrespective of activation state memento_.template create (*oAh.memento_); } diff --git a/src/proc/control/command-impl.hpp b/src/proc/control/command-impl.hpp index f209ba3c0..456cc4c28 100644 --- a/src/proc/control/command-impl.hpp +++ b/src/proc/control/command-impl.hpp @@ -178,7 +178,7 @@ namespace control { canExec() const ///< state check: sufficiently defined to be invoked { return isValid() - && *pClo_; + && pClo_->isValid(); } bool @@ -188,18 +188,24 @@ namespace control { } - + friend bool operator== (CommandImpl const& ci1, CommandImpl const& ci2) { return (ci1.do_ == ci2.do_) - && (ci1.undo_ == ci2.undo_) +// && (ci1.undo_ == ci2.undo_) // causes failure regularly, due to the missing equality on boost::function. See Ticket #294 && (ci1.defaultPatt_ == ci2.defaultPatt_) && (ci1.canExec() == ci2.canExec()) && (ci1.canUndo() == ci2.canUndo()) && (ci1.pClo_->equals(*ci2.pClo_)) ; } + + friend bool + operator!= (CommandImpl const& ci1, CommandImpl const& ci2) + { + return !(ci1==ci2); + } }; diff --git a/tests/45controller.tests b/tests/45controller.tests index bce8c19b9..ec2cf9d47 100644 --- a/tests/45controller.tests +++ b/tests/45controller.tests @@ -60,7 +60,7 @@ return: 0 END -PLANNED "Command index and allocation" CommandRegistry_test <isValid()); + ASSERT (!pImpl->canExec()); ASSERT (1 == pImpl.use_count()); // no magic involved, we hold the only instance PImpl clone = registry.createCloneImpl(*pImpl); ASSERT (clone->isValid()); + ASSERT (!clone->canExec()); ASSERT (1 == clone.use_count()); ASSERT (1 == pImpl.use_count()); ASSERT (2+cnt_inst == registry.instance_count()); ASSERT (!isSameObject (*pImpl, *clone)); -// ASSERT (*pImpl == *clone); ///////////////////////////////////////TODO: comparison on CommandImpl ?? + ASSERT (*pImpl == *clone); ASSERT (!pImpl->canExec()); typedef Types ArgType; @@ -203,13 +215,13 @@ namespace test { pImpl->setArguments(arg); ASSERT (pImpl->canExec()); -// ASSERT (*pImpl != *clone); // this proves the clone has indeed a separate identity - ASSERT (!clone->canExec()); + ASSERT (!clone->canExec()); // this proves the clone has indeed a separate identity + ASSERT (*pImpl != *clone); // discard the first clone and overwrite with a new one clone = registry.createCloneImpl(*pImpl); ASSERT (2+cnt_inst == registry.instance_count()); -// ASSERT (*pImpl == *clone); + ASSERT (*pImpl == *clone); ASSERT (clone->canExec()); clone.reset(); @@ -223,6 +235,6 @@ namespace test { /** Register this test class... */ LAUNCHER (CommandRegistry_test, "function controller"); - - + + }} // namespace control::test