void AnimatedSprite::update(const sf::Time& deltaTime)
 {
     if(_status == Playing and _animation)
     {
         _elapsed += deltaTime;
         if(_elapsed > _delta)
         {
             _elapsed -= _delta;
             if(_currentFrame + 1 < _animation->size())
                 ++_currentFrame;
             else
             {
                 _currentFrame = 0;
                 if(not _loop)
                 {
                     --_repeat;
                     if(_repeat<=0)
                     {
                         _status = Stopped;
                         on_finished();
                     }
                 }
             }
         }
         setFrame(_currentFrame,false);
     }
 }
Beispiel #2
0
void CWindowMain::on_execut(const QList<CExecutObject *> &lstObj)
{
    if (!lstObj.isEmpty() && m_executThread == NULL) {

        m_executThread = new CExecutThread(this,lstObj);

        connect(m_executThread,SIGNAL(executOperation(QString)),
                m_widgetConsol,SLOT(executingOperation(QString)));

        connect(m_executThread,SIGNAL(message(QString)),
                m_widgetConsol,SLOT(messageAppend(QString)));

        connect(m_executThread,SIGNAL(started()),
                this,SIGNAL(locked()));

        connect(m_executThread,SIGNAL(timerWork(uint)),
                this,SLOT(on_timerWork(uint)));

        connect(this,SIGNAL(terminated()),
                m_executThread,SLOT(on_terminated()));

        connect(m_executThread,SIGNAL(finished()),
                this,SIGNAL(unlocked()));

        connect(m_executThread,SIGNAL(finished()),
                this,SLOT(on_finished()));

        m_executThread->start();
    }
}
Beispiel #3
0
/**
 * @brief Calls the on_finished() method of a Lua menu.
 * @param menu_ref A reference to the menu object.
 */
void LuaContext::menu_on_finished(int menu_ref) {

  push_ref(l, menu_ref);
  on_finished();
  remove_timers(-1);  // Stop timers associated to this menu.
  lua_pop(l, 1);
}
Beispiel #4
0
RetrieveFiles::RetrieveFiles(QString name, QObject * parent) : PActionItem(name, parent)
{
   thread = new RetrieveFilesThread(this);
   if (!connect(thread,SIGNAL(finished()), this, SLOT(on_finished())))
   {
      general_errors.error("Could not connect retrieve files finished signal");
   }
}
Beispiel #5
0
/**
 * \brief Calls sol.main.on_finished() if it exists.
 *
 * This function is called when the program is reset or stopped.
 */
void LuaContext::main_on_finished() {

  push_main(l);
  on_finished();
  remove_timers(-1);  // Stop timers associated to sol.main.
  remove_menus(-1);  // Stop menus associated to sol.main.
  lua_pop(l, 1);
}
Beispiel #6
0
/**
 * \brief Calls the on_finished() method of a Lua menu.
 * \param menu_ref A reference to the menu object.
 */
void LuaContext::menu_on_finished(const ScopedLuaRef& menu_ref) {

  push_ref(l, menu_ref);
  remove_menus(-1);  // First, stop children menus if any.
  on_finished();
  remove_timers(-1);  // Stop timers associated to this menu.
  lua_pop(l, 1);
}
Beispiel #7
0
/**
 * @brief Calls the on_finished() method of a Lua game.
 * @param game A game.
 */
void LuaContext::game_on_finished(Game& game) {

  push_game(l, game.get_savegame());
  on_finished();
  remove_timers(-1);  // Stop timers and menus associated to this game.
  remove_menus(-1);
  lua_pop(l, 1);
}
Beispiel #8
0
/**
 * \brief Calls the on_finished() method of a Lua equipment item.
 *
 * Does nothing if the method is not defined.
 *
 * \param item An equipment item.
 */
void LuaContext::item_on_finished(EquipmentItem& item) {

  push_item(l, item);
  if (userdata_has_field(item, "on_finished")) {
    on_finished();
  }
  remove_timers(-1);  // Stop timers and menus associated to this item.
  remove_menus(-1);
  lua_pop(l, 1);
}
Beispiel #9
0
 void speech_processor::finish()
 {
   if(!input.empty())
     {
       on_input();
       input.clear();
       if(is_stopped())
         return;
     }
   on_end_of_input();
   if(is_stopped())
     return;
   on_output();
   if(is_stopped())
     return;
   if(!next)
     {
       on_finished();
       return;
     }
   if(!insertion.empty())
     {
       next->insert(&insertion[0],insertion.size());
       insertion.clear();
       if(is_stopped())
         {
           output.clear();
           return;
         }
     }
   if(!output.empty())
     {
       next->process(&output[0],output.size());
       output.clear();
     }
   if(is_stopped())
     return;
   next->finish();
   if(is_stopped())
     return;
   on_finished();
 }
Beispiel #10
0
DiffCm::DiffCm(QString name, QObject * parent) : PActionItem(name, parent)
{
   thread = new DiffCmThread(this);
   if (!connect(thread, SIGNAL(finished()), this, SLOT(on_finished())))
   {
      general_errors.error("Could not connect");
   }
   QString cm;
   getVar("cm", cm);
   thread->setPath(cm);
}
Beispiel #11
0
MainWindow::MainWindow(QWidget *parent) :
    QMainWindow(parent),
    ui(new Ui::MainWindow)
{

    ui->setupUi(this);

    connect(&this->test,SIGNAL(updateState(QString)),this,SLOT(updateStatus(QString)));
    connect(&this->test,SIGNAL(workFinish(QList<QString>)),this,SLOT(on_finished(QList<QString>)));

}
Beispiel #12
0
EventProcessingBlockInOwnThread::~EventProcessingBlockInOwnThread ()
{
    QObject::disconnect(this, SIGNAL(terminated()), this, SLOT(on_terminated()));
    QObject::disconnect(this, SIGNAL(finished  ()), this, SLOT(on_finished  ()));
    QObject::disconnect(this, SIGNAL(started   ()), this, SLOT(on_started   ()));

    QObject::disconnect(this, SIGNAL(dbg_terminated(EventProcessingBlockInOwnThread*)), &debugger(), SLOT(terminated(EventProcessingBlockInOwnThread*)));
    QObject::disconnect(this, SIGNAL(dbg_finished  (EventProcessingBlockInOwnThread*)), &debugger(), SLOT(finished  (EventProcessingBlockInOwnThread*)));
    QObject::disconnect(this, SIGNAL(dbg_started   (EventProcessingBlockInOwnThread*)), &debugger(), SLOT(started   (EventProcessingBlockInOwnThread*)));

    debugger().destroyed(this);
}
Beispiel #13
0
EventProcessingBlockInOwnThread::EventProcessingBlockInOwnThread (Name name)
: name(name)
{
    debugger().constructed(this);

    QObject::connect(this, SIGNAL(dbg_started   (EventProcessingBlockInOwnThread*)), &debugger(), SLOT(started   (EventProcessingBlockInOwnThread*)));
    QObject::connect(this, SIGNAL(dbg_finished  (EventProcessingBlockInOwnThread*)), &debugger(), SLOT(finished  (EventProcessingBlockInOwnThread*)));
    QObject::connect(this, SIGNAL(dbg_terminated(EventProcessingBlockInOwnThread*)), &debugger(), SLOT(terminated(EventProcessingBlockInOwnThread*)));

    QObject::connect(this, SIGNAL(started   ()), this, SLOT(on_started   ()));
    QObject::connect(this, SIGNAL(finished  ()), this, SLOT(on_finished  ()));
    QObject::connect(this, SIGNAL(terminated()), this, SLOT(on_terminated()));
}
Beispiel #14
0
int DiffCm::qt_metacall(QMetaObject::Call _c, int _id, void **_a)
{
    _id = PActionItem::qt_metacall(_c, _id, _a);
    if (_id < 0)
        return _id;
    if (_c == QMetaObject::InvokeMetaMethod) {
        switch (_id) {
        case 0: on_finished(); break;
        default: ;
        }
        _id -= 1;
    }
    return _id;
}
Beispiel #15
0
/**
 * \brief Calls the on_finished() method of a Lua game if it is defined.
 *
 * Also stops timers and menus associated to the game.
 *
 * \param game A game.
 */
void LuaContext::game_on_finished(Game& game) {

  if (!game.get_savegame().is_known_to_lua()) {
    return;
  }

  push_game(l, game.get_savegame());
  if (userdata_has_field(game.get_savegame(), "on_finished")) {
    on_finished();
  }
  remove_timers(-1);  // Stop timers and menus associated to this game.
  remove_menus(-1);
  lua_pop(l, 1);
}
void RemoteFileCopier::Session::cancel() {
    BAIDU_SCOPED_LOCK(_mutex);
    if (_finished) {
        return; 
    }
    brpc::StartCancel(_rpc_call);
    if (bthread_timer_del(_timer) == 0) {
        // Release reference of the timer task
        Release();
    }
    if (_st.ok()) {
        _st.set_error(ECANCELED, "%s", berror(ECANCELED));
    }
    on_finished();
}
Beispiel #17
0
int RetrieveFiles::qt_metacall(QMetaObject::Call _c, int _id, void **_a)
{
    _id = PActionItem::qt_metacall(_c, _id, _a);
    if (_id < 0)
        return _id;
    if (_c == QMetaObject::InvokeMetaMethod) {
        switch (_id) {
        case 0: on_retrieve((*reinterpret_cast< bool(*)>(_a[1]))); break;
        case 1: on_finished(); break;
        default: ;
        }
        _id -= 2;
    }
    return _id;
}
void RemoteFileCopier::Session::on_rpc_returned() {
    scoped_refptr<Session> ref_gurad;
    Session* this_ref = this;
    ref_gurad.swap(&this_ref);
    std::unique_lock<raft_mutex_t> lck(_mutex);
    if (_finished) {
        return;
    }
    if (_cntl.Failed()) {
        // Reset count to make next rpc retry the previous one
        _request.set_count(0);
        if (_cntl.ErrorCode() == ECANCELED) {
            if (_st.ok()) {
                _st.set_error(_cntl.ErrorCode(), _cntl.ErrorText());
                return on_finished();
            }
        }
        // Throttled reading failure does not increase _retry_times
        if (_cntl.ErrorCode() != EAGAIN && _retry_times++ >= _options.max_retry) {
            if (_st.ok()) {
                _st.set_error(_cntl.ErrorCode(), _cntl.ErrorText());
                return on_finished();
            }
        }
        AddRef();
        if (bthread_timer_add(
                    &_timer, 
                    butil::milliseconds_from_now(_options.retry_interval_ms),
                    on_timer, this) != 0) {
            lck.unlock();
            LOG(ERROR) << "Fail to add timer";
            return on_timer(this);
        }
        return;
    }
    _retry_times = 0;
    // Reset count to |real_read_size| to make next rpc get the right offset
    if (_response.has_read_size() && (_response.read_size() != 0)) {
        _request.set_count(_response.read_size());
    }
    if (_file) {
        FileSegData data(_cntl.response_attachment());
        uint64_t seg_offset = 0;
        butil::IOBuf seg_data;
        while (0 != data.next(&seg_offset, &seg_data)) {
            ssize_t nwritten = _file->write(seg_data, seg_offset);
            if (static_cast<size_t>(nwritten) != seg_data.size()) {
                LOG(WARNING) << "Fail to write into file: " << _dest_path;
                _st.set_error(EIO, "%s", berror(EIO));
                return on_finished();
            }
            seg_data.clear();
        }
    } else {
        FileSegData data(_cntl.response_attachment());
        uint64_t seg_offset = 0;
        butil::IOBuf seg_data;
        while (0 != data.next(&seg_offset, &seg_data)) {
            CHECK_GE((size_t)seg_offset, _buf->length());
            _buf->resize(seg_offset);
            _buf->append(seg_data);
        }
    }
    if (_response.eof()) {
        on_finished();
        return;
    }
    lck.unlock();
    return send_next_rpc();
}