From b5b5ab6eb0ffac158cd505b130c0353f8be9d083 Mon Sep 17 00:00:00 2001 From: Luca Della Vedova Date: Fri, 7 Jul 2023 12:52:44 +0800 Subject: [PATCH] Fix panic with new workspaces (#131) Signed-off-by: Luca Della Vedova Co-authored-by: Grey --- rmf_site_editor/src/workspace.rs | 10 ++++++++-- rmf_site_format/src/level.rs | 2 +- 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/rmf_site_editor/src/workspace.rs b/rmf_site_editor/src/workspace.rs index 96a923cc..ef7ec73f 100644 --- a/rmf_site_editor/src/workspace.rs +++ b/rmf_site_editor/src/workspace.rs @@ -17,6 +17,7 @@ use bevy::{prelude::*, tasks::AsyncComputeTaskPool}; use rfd::AsyncFileDialog; +use std::collections::BTreeMap; use std::path::PathBuf; use crate::interaction::InteractionState; @@ -24,7 +25,7 @@ use crate::site::LoadSite; use crate::workcell::LoadWorkcell; use crate::AppState; use rmf_site_format::legacy::building_map::BuildingMap; -use rmf_site_format::{Site, SiteProperties, Workcell}; +use rmf_site_format::{Level, Site, SiteProperties, Workcell}; use crossbeam_channel::{Receiver, Sender}; @@ -137,8 +138,13 @@ pub fn dispatch_new_workspace_events( println!("DEV ERROR: Sent generic change workspace while in main menu"); } AppState::SiteEditor => { + let mut levels = BTreeMap::new(); + levels.insert(0, Level::default()); load_site.send(LoadSite { - site: Site::default(), + site: Site { + levels, + ..default() + }, focus: true, default_file: None, }); diff --git a/rmf_site_format/src/level.rs b/rmf_site_format/src/level.rs index 39de1b5f..f6322384 100644 --- a/rmf_site_format/src/level.rs +++ b/rmf_site_format/src/level.rs @@ -38,7 +38,7 @@ impl Default for LevelProperties { } } -#[derive(Serialize, Deserialize, Debug, Clone)] +#[derive(Serialize, Deserialize, Debug, Clone, Default)] pub struct Level { pub properties: LevelProperties, pub anchors: BTreeMap,