Skip to content

Commit 880e30e

Browse files
committed
Request redraw in wait block
1 parent 5a67268 commit 880e30e

File tree

2 files changed

+9
-2
lines changed

2 files changed

+9
-2
lines changed

src/dev/blocks/controlblocks.cpp

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@ CompilerValue *ControlBlocks::compileStop(Compiler *compiler)
8585
CompilerValue *ControlBlocks::compileWait(Compiler *compiler)
8686
{
8787
auto duration = compiler->addInput("DURATION");
88-
compiler->addFunctionCallWithCtx("control_start_stack_timer", Compiler::StaticType::Void, { Compiler::StaticType::Number }, { duration });
88+
compiler->addFunctionCallWithCtx("control_start_wait", Compiler::StaticType::Void, { Compiler::StaticType::Number }, { duration });
8989
compiler->createYield();
9090

9191
compiler->beginLoopCondition();
@@ -107,9 +107,10 @@ extern "C" void control_stop_other_scripts_in_target(ExecutionContext *ctx)
107107
ctx->engine()->stopTarget(thread->target(), thread);
108108
}
109109

110-
extern "C" void control_start_stack_timer(ExecutionContext *ctx, double seconds)
110+
extern "C" void control_start_wait(ExecutionContext *ctx, double seconds)
111111
{
112112
ctx->stackTimer()->start(seconds);
113+
ctx->engine()->requestRedraw();
113114
}
114115

115116
extern "C" bool control_stack_timer_elapsed(ExecutionContext *ctx)

test/dev/blocks/control_blocks_test.cpp

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -360,18 +360,22 @@ TEST_F(ControlBlocksTest, Wait)
360360
ctx->setStackTimer(&timer);
361361

362362
EXPECT_CALL(timer, start(2.5));
363+
EXPECT_CALL(m_engineMock, requestRedraw());
363364
code->run(ctx.get());
364365
ASSERT_FALSE(code->isFinished(ctx.get()));
365366

366367
EXPECT_CALL(timer, elapsed()).WillOnce(Return(false));
368+
EXPECT_CALL(m_engineMock, requestRedraw()).Times(0);
367369
code->run(ctx.get());
368370
ASSERT_FALSE(code->isFinished(ctx.get()));
369371

370372
EXPECT_CALL(timer, elapsed()).WillOnce(Return(false));
373+
EXPECT_CALL(m_engineMock, requestRedraw()).Times(0);
371374
code->run(ctx.get());
372375
ASSERT_FALSE(code->isFinished(ctx.get()));
373376

374377
EXPECT_CALL(timer, elapsed()).WillOnce(Return(true));
378+
EXPECT_CALL(m_engineMock, requestRedraw()).Times(0);
375379
code->run(ctx.get());
376380
ASSERT_TRUE(code->isFinished(ctx.get()));
377381
}
@@ -396,10 +400,12 @@ TEST_F(ControlBlocksTest, Wait)
396400
ctx->setStackTimer(&timer);
397401

398402
EXPECT_CALL(timer, start(0.0));
403+
EXPECT_CALL(m_engineMock, requestRedraw());
399404
code->run(ctx.get());
400405
ASSERT_FALSE(code->isFinished(ctx.get()));
401406

402407
EXPECT_CALL(timer, elapsed()).WillOnce(Return(true));
408+
EXPECT_CALL(m_engineMock, requestRedraw()).Times(0);
403409
code->run(ctx.get());
404410
ASSERT_TRUE(code->isFinished(ctx.get()));
405411
}

0 commit comments

Comments
 (0)