File tree Expand file tree Collapse file tree 2 files changed +24
-2
lines changed
Expand file tree Collapse file tree 2 files changed +24
-2
lines changed Original file line number Diff line number Diff line change 11use lazy_static:: lazy_static;
2- use std:: sync:: Mutex ;
2+ use std:: {
3+ sync:: Mutex ,
4+ thread:: sleep,
5+ time:: { Duration , Instant } ,
6+ } ;
37use windows:: {
48 core:: PCSTR ,
59 Win32 :: {
@@ -121,6 +125,24 @@ impl MemoryManager {
121125 ( * self . ptr ) . width = width;
122126 ( * self . ptr ) . height = height;
123127 }
128+
129+ pub unsafe fn wait_dimensions ( & self , time : u64 ) -> ( i32 , i32 ) {
130+ let start = Instant :: now ( ) ;
131+ let timeout = Duration :: from_millis ( time) ;
132+
133+ loop {
134+ let ( w, h) = self . get_dimensions ( ) ;
135+ if w > 0 && h > 0 {
136+ return ( w, h) ;
137+ }
138+
139+ if start. elapsed ( ) >= timeout {
140+ panic ! ( "[WaspInput]: Timeout waiting for valid dimensions!\r \n " ) ;
141+ }
142+
143+ sleep ( Duration :: from_millis ( 100 ) ) ;
144+ }
145+ }
124146}
125147
126148lazy_static ! {
Original file line number Diff line number Diff line change @@ -97,7 +97,7 @@ pub extern "C" fn SimbaPluginTarget_RequestWithDebugImage(
9797 . external_image_set_memory
9898 . expect ( "external_image_set_memory function pointer is null" ) ;
9999
100- let ( w, h) = mem_manager. get_dimensions ( ) ;
100+ let ( w, h) = mem_manager. wait_dimensions ( 5000 ) ;
101101
102102 let img = external_image_create ( true ) ;
103103 * overlay = img;
You can’t perform that action at this time.
0 commit comments