Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Ignore:
Timestamp:
Aug 30, 2010, 7:52:33 PM (14 years ago)
Author:
landauf
Message:

pushFunction() (which explicitly adds a new level to the console command stack) was not forwarded to ConsoleCommandManipulator

also fixed a bug which was caused by pushFunction() with a subsequent call to setFunction(…) because it may have unexpectedly changed the functor of the lower stack levels. now pushFunction() not only copyconstructs the executor, but also the Functor (with a clone() function)

Location:
code/branches/consolecommands3/src/libraries/core/command
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • code/branches/consolecommands3/src/libraries/core/command/ConsoleCommand.cc

    r7267 r7270  
    193193    {
    194194        Command command;
    195         command.executor_ = this->getExecutor();
     195        command.executor_ = this->executor_;
    196196        if (command.executor_)
    197             command.functor_ = this->getExecutor()->getFunctor();
     197            command.functor_ = this->executor_->getFunctor();
    198198
    199199        if (this->setFunction(executor, bForce))
     
    204204    {
    205205        Command command;
    206         command.executor_ = this->getExecutor();
     206        command.executor_ = this->executor_;
    207207        if (command.executor_)
    208             command.functor_ = this->getExecutor()->getFunctor();
     208            command.functor_ = this->executor_->getFunctor();
    209209
    210210        if (this->setFunction(functor, bForce))
  • code/branches/consolecommands3/src/libraries/core/command/ConsoleCommand.h

    r7267 r7270  
    142142                        { if (this->command_) { this->command_->setFunction(executor, bForce); } return *this; }
    143143
     144                    inline ConsoleCommandManipulator& pushFunction()
     145                        { if (this->command_) { this->command_->pushFunction(); } return *this; }
    144146                    template <class F>
    145147                    inline ConsoleCommandManipulator& pushFunction(F function, bool bForce = false)
  • code/branches/consolecommands3/src/libraries/core/command/Executor.cc

    r7265 r7270  
    4444        this->functor_ = functor;
    4545        this->name_ = name;
     46    }
     47
     48    Executor::Executor(const Executor& other) : name_(other.name_), defaultValue_(other.defaultValue_)
     49    {
     50        this->functor_ = other.functor_->clone();
    4651    }
    4752
  • code/branches/consolecommands3/src/libraries/core/command/Executor.h

    r7230 r7270  
    4444        public:
    4545            Executor(const FunctorPtr& functor, const std::string& name = "");
     46            Executor(const Executor& other);
    4647            virtual ~Executor();
    4748
  • code/branches/consolecommands3/src/libraries/core/command/Functor.h

    r7242 r7270  
    8585        public:
    8686            virtual MultiType operator()(const MultiType& param1 = MT_Type::Null, const MultiType& param2 = MT_Type::Null, const MultiType& param3 = MT_Type::Null, const MultiType& param4 = MT_Type::Null, const MultiType& param5 = MT_Type::Null) = 0;
     87
     88            virtual FunctorPtr clone() = 0;
    8789
    8890            virtual Type::Enum getType() const = 0;
     
    269271            }
    270272
     273            FunctorPtr clone()
     274            {
     275                return new FunctorTemplate(*this);
     276            }
     277
    271278            void evaluateParam(unsigned int index, MultiType& param) const
    272279            {
Note: See TracChangeset for help on using the changeset viewer.