File tree Expand file tree Collapse file tree 1 file changed +7
-5
lines changed
cosmic-settings/src/pages/bluetooth Expand file tree Collapse file tree 1 file changed +7
-5
lines changed Original file line number Diff line number Diff line change @@ -194,26 +194,28 @@ impl page::Page<crate::pages::Message> for Page {
194194 }
195195
196196 fn on_leave ( & mut self ) -> Task < crate :: pages:: Message > {
197+ let mut task = Task :: none ( ) ;
198+
197199 if let Some ( cancel) = self . subscription . take ( ) {
198200 _ = cancel. send ( ( ) ) ;
199201 }
200202
201203 if let Some ( connection) = self . connection . take ( ) {
202204 let adapters = self . model . adapters . clone ( ) ;
203205
204- // Block the current thread to ensure that discovery is stopped
205- // on all adapters when the app is closed.
206- Handle :: current ( ) . block_on ( async move {
206+ // Execute within task to ensure it completes before the app exits.
207+ task = Task :: future ( async move {
207208 for ( path, _) in adapters {
208209 stop_discovery ( connection. clone ( ) , path. clone ( ) ) . await ;
209210 }
210211 _ = agent:: unregister ( connection) . await ;
211- } ) ;
212+ } )
213+ . discard ( ) ;
212214 }
213215
214216 self . model . clear ( ) ;
215217
216- Task :: none ( )
218+ task
217219 }
218220
219221 fn dialog ( & self ) -> Option < Element < ' _ , crate :: pages:: Message > > {
You can’t perform that action at this time.
0 commit comments