From e6f3c7e4e42132e5c6b818436c12eee6c0674ed2 Mon Sep 17 00:00:00 2001 From: maj00r <73280030+maj00r@users.noreply.github.com> Date: Tue, 24 Nov 2026 20:11:01 +0100 Subject: [PATCH] fix(editor): a map opened on the model gets its project file also with nothing to migrate open_project() writes no project file when there are no //$ lines to migrate (#461), but the editing on the model relies on the map having its project file from the start: the self-test cases m_1_lay_managed and ps_2_setup_project failed with it absent. session::open() writes it when it isn't there. --- editor/project/projectSession.cpp | 4 ++++ tests/unit/test_project_session.cpp | 4 ++-- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/editor/project/projectSession.cpp b/editor/project/projectSession.cpp index 767da1738..755a6c641 100644 --- a/editor/project/projectSession.cpp +++ b/editor/project/projectSession.cpp @@ -59,6 +59,10 @@ session::open_result session::open(std::filesystem::path const &Folder, std::str m_model = layout::model{m_project.network}; m_open = true; result.done = true; + // a map edited on the model has its project file from the start, also with nothing to migrate, of which open_project() writes none + if (std::error_code missing; false == std::filesystem::exists(file(), missing)) + if (std::string error; false == save(error)) + result.notes.push_back("the project file isn't written: " + error); return result; } diff --git a/tests/unit/test_project_session.cpp b/tests/unit/test_project_session.cpp index 8463e1c7c..8f2498085 100644 --- a/tests/unit/test_project_session.cpp +++ b/tests/unit/test_project_session.cpp @@ -64,9 +64,9 @@ TEST_CASE("project session: the map opened gets its project, a command tried cha project::session session; auto const opened{session.open(folder.root(), "mapa.scn")}; REQUIRE(opened.done); - // nothing to migrate: no file yet, it's written as the scenery is saved + // nothing to migrate, and the map has its project file all the same: the session writes it as the map is opened CHECK_FALSE(opened.migrated); - CHECK_FALSE(std::filesystem::exists(folder.root() / "mapa.eu07proj")); + CHECK(std::filesystem::exists(folder.root() / "mapa.eu07proj")); CHECK(session.file() == folder.root() / "mapa.eu07proj"); CHECK(session.network().lines().empty());