Skip to content

Commit edb788e

Browse files
committed
Fix top level blocks without a position
1 parent afd3d0d commit edb788e

File tree

1 file changed

+8
-4
lines changed

1 file changed

+8
-4
lines changed

src/internal/scratch3reader.cpp

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -92,8 +92,10 @@ bool Scratch3Reader::load()
9292
reporterInfo->setValueId(jsonToValue(blockInfo[2]).toString());
9393
reporterInfo->setType(static_cast<InputValue::Type>(blockInfo[0]));
9494

95-
block->setX(blockInfo[3]);
96-
block->setY(blockInfo[4]);
95+
if (blockInfo.size() > 3) {
96+
block->setX(blockInfo[3]);
97+
block->setY(blockInfo[4]);
98+
}
9799

98100
target->addBlock(block);
99101
continue;
@@ -118,9 +120,11 @@ bool Scratch3Reader::load()
118120

119121
if (block->topLevel()) {
120122
READER_STEP(step, "target -> block -> x");
121-
block->setX(blockInfo["x"]);
123+
if (!blockInfo["x"].is_null())
124+
block->setX(blockInfo["x"]);
122125
READER_STEP(step, "target -> block -> y");
123-
block->setY(blockInfo["y"]);
126+
if (!blockInfo["y"].is_null())
127+
block->setY(blockInfo["y"]);
124128
}
125129

126130
// inputs

0 commit comments

Comments
 (0)