File tree Expand file tree Collapse file tree 1 file changed +11
-1
lines changed
tools/lsp/preview/connector Expand file tree Collapse file tree 1 file changed +11
-1
lines changed Original file line number Diff line number Diff line change @@ -196,19 +196,29 @@ impl Default for RemoteControlledPreviewToLsp {
196196}
197197
198198impl RemoteControlledPreviewToLsp {
199- /// Creates a RemoteConfrolledPreviewToLsp connector.
199+ /// Creates a RemoteControlledPreviewToLsp connector.
200200 ///
201201 /// This means the applications lifetime is bound to the lifetime of the
202202 /// application's STDIN: We quit as soon as that gets fishy or closed.
203203 ///
204204 /// It also means we do not need to join the reader thread: The OS will clean
205205 /// that one up for us anyway.
206+ ///
207+ /// Note: If the Slint backend has not been set yet, this will set a backend with the
208+ /// default Slint BackendSelector.
206209 pub fn new ( ) -> Self {
207210 let _ = Self :: process_input ( ) ;
208211 Self { }
209212 }
210213
211214 fn process_input ( ) -> std:: thread:: JoinHandle < std:: result:: Result < ( ) , String > > {
215+ // Ensure the backend is set up before the reader thread starts. This fixes
216+ // bug #10274 on macOS where a race condition was causing the reader thread to already
217+ // process messages before the event loop was running.
218+ //
219+ // Use .ok() to ignore any errors, as the backend might already be set by the user and that's fine.
220+ slint:: BackendSelector :: new ( ) . select ( ) . ok ( ) ;
221+
212222 std:: thread:: spawn ( move || -> Result < ( ) , String > {
213223 let reader = std:: io:: BufReader :: new ( std:: io:: stdin ( ) . lock ( ) ) ;
214224 for line in reader. lines ( ) {
You can’t perform that action at this time.
0 commit comments