@@ -128,11 +128,17 @@ impl WindowsPlatform {
128128 Some ( HWND_MESSAGE ) ,
129129 None ,
130130 None ,
131- Some ( & context as * const _ as * const _ ) ,
131+ Some ( & raw const context as * const _ ) ,
132132 )
133133 } ;
134- let inner = context. inner . take ( ) . unwrap ( ) ?;
135- let dispatcher = context. dispatcher . take ( ) . unwrap ( ) ;
134+ let inner = context
135+ . inner
136+ . take ( )
137+ . context ( "CreateWindowExW did not run correctly" ) ??;
138+ let dispatcher = context
139+ . dispatcher
140+ . take ( )
141+ . context ( "CreateWindowExW did not run correctly" ) ?;
136142 let handle = result?;
137143
138144 let disable_direct_composition = std:: env:: var ( DISABLE_DIRECT_COMPOSITION )
@@ -696,14 +702,24 @@ impl Platform for WindowsPlatform {
696702impl WindowsPlatformInner {
697703 fn new ( context : & mut PlatformWindowCreateContext ) -> Result < Rc < Self > > {
698704 let state = RefCell :: new ( WindowsPlatformState :: new (
699- context. directx_devices . take ( ) . unwrap ( ) ,
705+ context
706+ . directx_devices
707+ . take ( )
708+ . context ( "missing directx devices" ) ?,
700709 ) ) ;
701710 Ok ( Rc :: new ( Self {
702711 state,
703712 raw_window_handles : context. raw_window_handles . clone ( ) ,
704- dispatcher : context. dispatcher . as_ref ( ) . unwrap ( ) . clone ( ) ,
713+ dispatcher : context
714+ . dispatcher
715+ . as_ref ( )
716+ . context ( "missing dispatcher" ) ?
717+ . clone ( ) ,
705718 validation_number : context. validation_number ,
706- main_receiver : context. main_receiver . take ( ) . unwrap ( ) ,
719+ main_receiver : context
720+ . main_receiver
721+ . take ( )
722+ . context ( "missing main receiver" ) ?,
707723 } ) )
708724 }
709725
@@ -1152,13 +1168,16 @@ unsafe extern "system" fn window_procedure(
11521168 lparam : LPARAM ,
11531169) -> LRESULT {
11541170 if msg == WM_NCCREATE {
1155- let params = lparam. 0 as * const CREATESTRUCTW ;
1156- let params = unsafe { & * params } ;
1171+ let params = unsafe { & * ( lparam. 0 as * const CREATESTRUCTW ) } ;
11571172 let creation_context = params. lpCreateParams as * mut PlatformWindowCreateContext ;
11581173 let creation_context = unsafe { & mut * creation_context } ;
11591174
1175+ let Some ( main_sender) = creation_context. main_sender . take ( ) else {
1176+ creation_context. inner = Some ( Err ( anyhow ! ( "missing main sender" ) ) ) ;
1177+ return LRESULT ( 0 ) ;
1178+ } ;
11601179 creation_context. dispatcher = Some ( Arc :: new ( WindowsDispatcher :: new (
1161- creation_context . main_sender . take ( ) . unwrap ( ) ,
1180+ main_sender,
11621181 hwnd,
11631182 creation_context. validation_number ,
11641183 ) ) ) ;
0 commit comments