@@ -4,6 +4,7 @@ use super::keyboard::{make_modifiers, KeyboardState};
44use super :: window:: WindowSharedState ;
55use crate :: handler:: WindowHandlerBuilder ;
66use crate :: platform:: * ;
7+ use crate :: tracing:: warn;
78use crate :: wrappers:: appkit:: * ;
89use crate :: MouseEvent :: { ButtonPressed , ButtonReleased } ;
910use crate :: {
@@ -182,7 +183,10 @@ impl BaseviewView {
182183 }
183184
184185 fn trigger_frame ( this : ViewRef < Self > ) {
185- this. window_handler . use_handler ( |h| h. on_frame ( ) ) ;
186+ if let Some ( Err ( e) ) = this. window_handler . use_handler ( |h| h. on_frame ( ) ) {
187+ warn ! ( "Error while rendering frame: {}" , e) ;
188+ Self :: close ( this) ;
189+ }
186190 }
187191}
188192
@@ -226,12 +230,18 @@ impl ViewImpl for BaseviewView {
226230 if this. state . scale_factor . get ( ) != current_scale_factor
227231 || this. state . size . get ( ) != current_size
228232 {
229- this. state . size . set ( current_size) ;
233+ let previous = this. state . size . replace ( current_size) ;
230234 this. state . scale_factor . set ( current_scale_factor) ;
231235
232- this. window_handler . use_handler ( |h| {
236+ let result = this. window_handler . use_handler ( |h| {
233237 h. resized ( WindowSize :: from_logical ( current_size, current_scale_factor) )
234238 } ) ;
239+
240+ if let Some ( Err ( e) ) = result {
241+ warn ! ( "Window Handler failed to resize: {}" , e) ;
242+ this. state . size . set ( previous) ;
243+ Self :: resize ( this, previous. into ( ) )
244+ }
235245 }
236246 }
237247
0 commit comments