Project

General

Profile

Actions

Bug #4116

open

Reset of WTimer interval on stop and start

Added by Markus Wolters almost 9 years ago. Updated almost 9 years ago.

Status:
Feedback
Priority:
Normal
Assignee:
Benoit Daccache
Target version:
-
Start date:
05/27/2015
Due date:
% Done:

0%

Estimated time:

Description

I try to reset the WTimer interval with a combination of stop() and start(), but it continues on the previously set interval. If elapsed, the timeout is resetted as expected, but never before.

@

init:

resetTimer = new Wt::WTimer();

resetTimer->setInterval(10000);

resetTimer->timeout().connect(this, &StatusView::onResetTimeout);

resetTimer->setSingleShot(true);

resetTimer->start();

@

@

event method:

resetTimer->stop();

doMyStuff();

resetTimer->start();

@

Actions #1

Updated by Koen Deforche almost 9 years ago

  • Status changed from New to InProgress
  • Assignee set to Benoit Daccache
Actions #2

Updated by Benoit Daccache almost 9 years ago

Hey Markus,

I'm not able to reproduce the problem with the following code :

timer_ = new WTimer();
  timer_->setInterval(10000);
  timer_->setSingleShot(true);
  timer_->start();
  std::cerr << "Timer started at : " << std::time(0)<< std::endl;
  sleep(2);
  timer_->stop();
  std::cerr << "Timer stopped at : " << std::time(0) << std::endl;
  sleep(3);
  timer_->start();
  std::cerr << "Timer restarted at : " << std::time(0)<< std::endl;

  timer_->timeout().connect(std::bind([=]() {
    std::cerr << "End of timer : " << std::time(0) << std::endl;
        }));

I get the following output which seems correct to me :

 <code>

Timer started at : 1432820793
Timer stopped at : 1432820795
Timer restarted at : 1432820798
[2015-May-28 15:46:38.436877] 4985 - [info] "WebRequest: took 5245.52ms"
127.0.0.1 - - [2015-May-28 15:46:38.437357] "GET /?wtd=r6NiMJ18nOulJxet&request=style&page=1 HTTP/1.1" 200 91
127.0.0.1 - - [2015-May-28 15:46:38.439794] "GET /resources/themes/default/wt.css HTTP/1.1" 304 0
127.0.0.1 - - [2015-May-28 15:46:38.439902] "GET /resources/webkit-transitions.css HTTP/1.1" 304 0
[2015-May-28 15:46:38.445580] 4985 - [info] "WebRequest: took 5011.98ms"
127.0.0.1 - - [2015-May-28 15:46:38.460963] "GET /?wtd=r6NiMJ18nOulJxet&sid=1164332058&webGL=true&scrW=1920&scrH=1080&tz=120&htmlHistory=true&deployPath=%2F&request=script&rand=3408971808 HTTP/1.1" 200 45366
[2015-May-28 15:46:38.541146] 4985 - [info] "WebRequest: took 0.74ms"
127.0.0.1 - - [2015-May-28 15:46:38.541901] "POST /?wtd=r6NiMJ18nOulJxet HTTP/1.1" 200 50
End of timer : 1432820808

I also to trigger a start stop on a event :

 <code class="cpp">

 timer_ = new WTimer();
  button_ = new WPushButton("work");
  timer_->setInterval(10000);
  timer_->setSingleShot(true);
  timer_->timeout().connect(std::bind([=]() {
    std::cerr << "End of timer : " << std::time(0) << std::endl;
        }));

  button_->clicked().connect(std::bind([=]() { 
        if(timer_->isActive()) {
        timer_->stop();
        std::cerr << "Timer stopped at : " << std::time(0) << std::endl;
        }
        else {
        timer_->start();
        std::cerr << "Timer restarted at : " << std::time(0) << std::endl;
        }
        }));
  std::time_t t = std::time(0);
  timer_->start();
  std::cerr << "Timer started at : " << t << std::endl;

With no luck.

Can you provide me a test case where you can reproduce the problem ?

Thank you

Regards,

Benoit

Actions #3

Updated by Koen Deforche almost 9 years ago

  • Status changed from InProgress to Feedback
Actions

Also available in: Atom PDF