@@ -178,13 +178,18 @@ impl ArtboardToolData {
178178 let Some ( movement) = & bounds. selected_edges else {
179179 return ;
180180 } ;
181- if self . selected_artboard == Some ( LayerNodeIdentifier :: ROOT_PARENT ) {
181+ let Some ( selected_artboard) = self . selected_artboard else {
182+ warn ! ( "Attempted to resize artboard with no selected artboard" ) ;
183+ self . bounding_box_manager . take ( ) ; // Remove the bounding box manager if there is no artboard.
184+ return ; // Just do nothing instead of crashing since the state likely isn't too broken.
185+ } ;
186+ if selected_artboard == LayerNodeIdentifier :: ROOT_PARENT {
182187 log:: error!( "Selected artboard cannot be ROOT_PARENT" ) ;
183188 return ;
184189 }
185190
186191 let center = from_center. then_some ( bounds. center_of_transformation ) ;
187- let ignore = self . selected_artboard . map_or ( Vec :: new ( ) , |layer| vec ! [ layer ] ) ;
192+ let ignore = vec ! [ selected_artboard ] ;
188193 let snap = Some ( SizeSnapData {
189194 manager : & mut self . draw . snap_manager ,
190195 points : & mut self . snap_candidates ,
@@ -196,14 +201,14 @@ impl ArtboardToolData {
196201 let size = ( max - min) . abs ( ) ;
197202
198203 responses. add ( GraphOperationMessage :: ResizeArtboard {
199- layer : self . selected_artboard . unwrap ( ) ,
204+ layer : selected_artboard,
200205 location : position. round ( ) . as_ivec2 ( ) ,
201206 dimensions : size. round ( ) . as_ivec2 ( ) ,
202207 } ) ;
203208
204209 let translation = position. round ( ) . as_ivec2 ( ) - self . dragging_current_artboard_location ;
205210 self . dragging_current_artboard_location = position. round ( ) . as_ivec2 ( ) ;
206- for child in self . selected_artboard . unwrap ( ) . children ( document. metadata ( ) ) {
211+ for child in selected_artboard. children ( document. metadata ( ) ) {
207212 let local_translation = document. metadata ( ) . downstream_transform_to_document ( child) . inverse ( ) . transform_vector2 ( -translation. as_dvec2 ( ) ) ;
208213 responses. add ( GraphOperationMessage :: TransformChange {
209214 layer : child,
@@ -235,6 +240,9 @@ impl Fsm for ArtboardToolFsmState {
235240 bounding_box_manager. transform = document. metadata ( ) . document_to_viewport ;
236241
237242 bounding_box_manager. render_overlays ( & mut overlay_context, true ) ;
243+ } else {
244+ // If the bounding box is not resolved (e.g. if the artboard is deleted), then discard the bounding box.
245+ tool_data. bounding_box_manager . take ( ) ;
238246 }
239247 } else {
240248 tool_data. bounding_box_manager . take ( ) ;
0 commit comments