From fa85ebe2b6fba729bfbeb9be7b35c74e2d1c0a1f Mon Sep 17 00:00:00 2001 From: LmeSzinc <37934724+LmeSzinc@users.noreply.github.com> Date: Sat, 18 May 2024 02:47:33 +0800 Subject: [PATCH] Fix: Empty planner rows are not preserved in config --- tasks/planner/model.py | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/tasks/planner/model.py b/tasks/planner/model.py index 672ec832d..3b16307b5 100644 --- a/tasks/planner/model.py +++ b/tasks/planner/model.py @@ -383,9 +383,8 @@ class PlannerMixin(UI): """ Write planner detection results info user config """ - model = PlannerProgressParser().from_planner_results(results) - data = model.to_config() - self.config.cross_set('Dungeon.Planner', data) + planner = PlannerProgressParser().from_planner_results(results) + self.planner_write(planner) @cached_property def planner(self) -> PlannerProgressParser: @@ -396,10 +395,16 @@ class PlannerMixin(UI): logger.info(row) return model - def planner_write(self): + def planner_write(self, planner=None): """ Write planner into user config, delete planner object """ - data = self.planner.to_config() - self.config.cross_set('Dungeon.Planner', data) + if planner is None: + planner = self.planner + + data = planner.to_config() + + with self.config.multi_set(): + for key, value in data.items(): + self.config.cross_set(f'Dungeon.Planner.{key}', value) del_cached_property(self, 'planner')