Skip to content

Commit d54ccbc

Browse files
committed
InputValue: Set block ID properly
1 parent f10056f commit d54ccbc

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

src/scratch/inputvalue.cpp

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
#include <scratchcpp/inputvalue.h>
44
#include <scratchcpp/compiler.h>
5-
#include <scratchcpp/entity.h>
5+
#include <scratchcpp/block.h>
66
#include <scratchcpp/broadcast.h>
77
#include <scratchcpp/variable.h>
88
#include <scratchcpp/list.h>
@@ -86,6 +86,11 @@ const std::shared_ptr<Block> &InputValue::valueBlock() const
8686
void InputValue::setValueBlock(const std::shared_ptr<Block> &newValueBlock)
8787
{
8888
impl->valueBlock = newValueBlock;
89+
90+
if (newValueBlock)
91+
impl->valueBlockId = newValueBlock->id();
92+
else
93+
impl->valueBlockId = "";
8994
}
9095

9196
/*! Returns the ID of the block. \see valueBlock() */
@@ -98,6 +103,7 @@ const std::string &InputValue::valueBlockId() const
98103
void InputValue::setValueBlockId(const std::string &newValueBlockId)
99104
{
100105
impl->valueBlockId = newValueBlockId;
106+
impl->valueBlock = nullptr;
101107
}
102108

103109
/*! Returns a pointer to the value (e. g. a variable). */

0 commit comments

Comments
 (0)