Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 8 additions & 4 deletions src/internal/scratch3reader.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -404,12 +404,16 @@ bool Scratch3Reader::load()
}

// width
READER_STEP(step, "monitor -> width");
monitor->setWidth(jsonMonitor["width"]);
if (jsonMonitor.contains("width")) {
READER_STEP(step, "monitor -> width");
monitor->setWidth(jsonMonitor["width"]);
}

// height
READER_STEP(step, "monitor -> height");
monitor->setHeight(jsonMonitor["height"]);
if (jsonMonitor.contains("height")) {
READER_STEP(step, "monitor -> height");
monitor->setHeight(jsonMonitor["height"]);
}

// x
READER_STEP(step, "monitor -> x");
Expand Down
8 changes: 8 additions & 0 deletions test/load_project/load_project_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -701,3 +701,11 @@ TEST(LoadProjectTest, ProjectInvalidTest)
ASSERT_EQ(p.scratchVersion(), ScratchVersion::Invalid);
ASSERT_FALSE(p.load());
}

TEST(LoadProjectTest, LoadNullDimensionMonitor)
{
// Regtest for #448
std::string name = "regtest_projects/448_null_monitor_dimension.sb3";
Project p(name);
ASSERT_TRUE(p.load());
}
Binary file added test/regtest_projects/448_null_monitor_dimension.sb3
Binary file not shown.