diff --git a/src/projectloader.cpp b/src/projectloader.cpp index 85a53ee..d8c6fea 100644 --- a/src/projectloader.cpp +++ b/src/projectloader.cpp @@ -251,6 +251,11 @@ void ProjectLoader::callLoad(ProjectLoader *loader) void ProjectLoader::load() { m_unpositionedMonitors.clear(); + m_sprites.clear(); + m_clones.clear(); + emit spritesChanged(); + emit clonesChanged(); + m_loadStatus = m_project.load(); m_engineMutex.lock(); m_engine = m_project.engine().get(); @@ -262,6 +267,7 @@ void ProjectLoader::load() emit loadingFinished(); emit engineChanged(); emit spritesChanged(); + emit clonesChanged(); return; } @@ -308,6 +314,7 @@ void ProjectLoader::load() emit loadingFinished(); emit engineChanged(); emit spritesChanged(); + emit clonesChanged(); return; } @@ -327,6 +334,7 @@ void ProjectLoader::load() emit engineChanged(); emit stageChanged(); emit spritesChanged(); + emit clonesChanged(); } void ProjectLoader::initTimer() diff --git a/test/projectloader/projectloader_test.cpp b/test/projectloader/projectloader_test.cpp index db430a3..5684efa 100644 --- a/test/projectloader/projectloader_test.cpp +++ b/test/projectloader/projectloader_test.cpp @@ -57,8 +57,8 @@ class ProjectLoaderTest : public testing::Test ASSERT_EQ(loadingFinishedSpy.count(), 1); ASSERT_EQ(engineSpy.count(), 2); ASSERT_EQ(stageSpy.count(), 1); - ASSERT_EQ(spritesSpy.count(), 2); - ASSERT_EQ(clonesSpy.count(), 1); + ASSERT_EQ(spritesSpy.count(), 3); + ASSERT_EQ(clonesSpy.count(), 3); ASSERT_EQ(monitorsSpy.count(), loader->monitorList().size() + 1); ASSERT_EQ(monitorAddedSpy.count(), loader->monitorList().size()); ASSERT_EQ(unsupportedBlocksSpy.count(), 1); @@ -137,13 +137,13 @@ TEST_F(ProjectLoaderTest, Clones) load(&loader, "clones.sb3"); ASSERT_TRUE(cloneCreatedSpy.empty()); ASSERT_TRUE(cloneDeletedSpy.empty()); - ASSERT_EQ(clonesChangedSpy.count(), 1); + ASSERT_EQ(clonesChangedSpy.count(), 3); auto engine = loader.engine(); engine->run(); ASSERT_EQ(cloneCreatedSpy.count(), 3); ASSERT_EQ(cloneDeletedSpy.count(), 0); - ASSERT_EQ(clonesChangedSpy.count(), 4); + ASSERT_EQ(clonesChangedSpy.count(), 6); const auto &sprites = loader.spriteList(); const auto &clones = loader.cloneList(); @@ -162,7 +162,7 @@ TEST_F(ProjectLoaderTest, Clones) clones[1]->sprite()->deleteClone(); ASSERT_EQ(cloneCreatedSpy.count(), 3); ASSERT_EQ(cloneDeletedSpy.count(), 1); - ASSERT_EQ(clonesChangedSpy.count(), 5); + ASSERT_EQ(clonesChangedSpy.count(), 7); ASSERT_EQ(clones.size(), 2); }