@@ -217,18 +217,21 @@ impl ServerState {
217217 /// - `filename`: The path to the filename to be read for SBP messages.
218218 pub fn connect_to_file (
219219 & self ,
220- mut client_send : ClientSender ,
220+ client_send : ClientSender ,
221221 shared_state : SharedState ,
222222 filename : String ,
223223 close_when_done : bool ,
224224 ) -> Result < ( ) > {
225225 let conn = Connection :: file ( filename. clone ( ) ) ?;
226226 info ! ( "Opened file successfully!" ) ;
227227 shared_state. update_file_history ( filename) ;
228- self . connect ( conn, client_send. clone ( ) , shared_state, RealtimeDelay :: On ) ;
229- if close_when_done {
230- close_frontend ( & mut client_send) ;
231- }
228+ self . connect (
229+ conn,
230+ client_send,
231+ shared_state,
232+ RealtimeDelay :: On ,
233+ close_when_done,
234+ ) ;
232235 Ok ( ( ) )
233236 }
234237
@@ -249,7 +252,7 @@ impl ServerState {
249252 let conn = Connection :: tcp ( host. clone ( ) , port) ?;
250253 info ! ( "Connected to tcp stream!" ) ;
251254 shared_state. update_tcp_history ( host, port) ;
252- self . connect ( conn, client_send, shared_state, RealtimeDelay :: Off ) ;
255+ self . connect ( conn, client_send, shared_state, RealtimeDelay :: Off , false ) ;
253256 Ok ( ( ) )
254257 }
255258
@@ -272,7 +275,7 @@ impl ServerState {
272275 let conn = Connection :: serial ( device, baudrate, flow) ?;
273276 info ! ( "Connected to serialport!" ) ;
274277 // serial port history?
275- self . connect ( conn, client_send, shared_state, RealtimeDelay :: Off ) ;
278+ self . connect ( conn, client_send, shared_state, RealtimeDelay :: Off , false ) ;
276279 Ok ( ( ) )
277280 }
278281
@@ -282,13 +285,17 @@ impl ServerState {
282285 mut client_send : ClientSender ,
283286 shared_state : SharedState ,
284287 delay : RealtimeDelay ,
288+ close_when_done : bool ,
285289 ) {
286290 shared_state. set_current_connection ( conn. name . clone ( ) ) ;
287291 shared_state. set_running ( true , client_send. clone ( ) ) ;
288292 self . connection_join ( ) ;
289293 self . new_connection ( thread:: spawn ( move || {
290294 refresh_navbar ( & mut client_send, shared_state. clone ( ) ) ;
291295 process_messages ( conn, shared_state. clone ( ) , client_send. clone ( ) , delay) ;
296+ if close_when_done {
297+ close_frontend ( & mut client_send) ;
298+ }
292299 shared_state. set_running ( false , client_send) ;
293300 } ) ) ;
294301 }
0 commit comments