@@ -5,14 +5,14 @@ use crate::download::downloader::{DownloadStatus, NavdataDownloader};
5
5
use msfs:: { commbus:: * , MSFSEvent } ;
6
6
7
7
pub struct Dispatcher < ' a > {
8
- commbus : Option < CommBus < ' a > > ,
8
+ commbus : CommBus < ' a > ,
9
9
downloader : Rc < NavdataDownloader > ,
10
10
}
11
11
12
12
impl < ' a > Dispatcher < ' a > {
13
13
pub fn new ( ) -> Self {
14
14
Dispatcher {
15
- commbus : None ,
15
+ commbus : CommBus :: new ( ) ,
16
16
downloader : Rc :: new ( NavdataDownloader :: new ( ) ) ,
17
17
}
18
18
}
@@ -27,7 +27,7 @@ impl<'a> Dispatcher<'a> {
27
27
}
28
28
MSFSEvent :: PreKill => {
29
29
// Drop commbus so that we in turn unregister the events. TODO wait for the unregister functions to be ported into the msfs-rs library
30
- self . commbus = None ;
30
+ CommBus :: unregister_all ( ) ;
31
31
}
32
32
33
33
_ => { }
@@ -37,9 +37,9 @@ impl<'a> Dispatcher<'a> {
37
37
fn handle_initialized ( & mut self ) {
38
38
CommBus :: call ( "NAVIGRAPH_Initialized" , "" , CommBusBroadcastFlags :: All ) ;
39
39
let captured_downloader = self . downloader . clone ( ) ;
40
- self . commbus = CommBus :: register ( "NAVIGRAPH_DownloadNavdata" , move |args| {
40
+ self . commbus . register ( "NAVIGRAPH_DownloadNavdata" , move |args| {
41
41
captured_downloader. download ( args)
42
- } ) ;
42
+ } ) . expect ( "Failed to register NAVIGRAPH_DownloadNavdata" ) ;
43
43
}
44
44
45
45
fn handle_update ( & mut self ) {
0 commit comments