fsm icon indicating copy to clipboard operation
fsm copied to clipboard

Find a bug in line 206

Open KevinWang-kk opened this issue 4 years ago • 0 comments

Dear author I found unable to pass parameters when using your code. my code:

   void test(){
        int ret = 4;
        fsm::state s(STATE_ERROR);
        fsm.set(s(ret));
    }
    fsm.on(STATE_ERROR, 'init') = [&](const fsm::args &args){
        std::vector<std::string> a = args;
        int s = a.size();// s = 0?
    };

Make the following changes to line 206 and it's back to normal.

bool call( const fsm::state &from, const fsm::state &to ) const {
    std::map< bistate, fsm::call >::const_iterator found = callbacks.find(bistate(from,to));
    if( found != callbacks.end() ) {
        log.push_back( { from, current_trigger, to } );
        if( log.size() > 50 ) {
            log.pop_front();
        }
        //found->second( to.args );  //old  ways
        found->second( from.args ); //new ways
        return true;
    }
    return false;
}

Looking forward to your reply and correction

KevinWang-kk avatar Dec 21 '20 07:12 KevinWang-kk