fix compiler errors when only gui feature enabled

This commit is contained in:
Mark 2024-10-03 04:23:07 +02:00
parent f41bec1423
commit 01e59249f5

View File

@ -214,50 +214,54 @@ fn main() {
} }
}) })
}; };
match mode { macro_rules! gui_modes {
#[cfg(feature = "speedy2d")] () => {{
Mode::Gui | Mode::GuiSyncplayerLocal { .. } | Mode::GuiSyncplayerNetwork => { let get_con: Arc<Mutex<musicdb_lib::server::get::Client<Box<dyn ClientIo + 'static>>>> =
{ Arc::new(Mutex::new(
let get_con: Arc<
Mutex<musicdb_lib::server::get::Client<Box<dyn ClientIo + 'static>>>,
> = Arc::new(Mutex::new(
musicdb_lib::server::get::Client::new(BufReader::new(Box::new( musicdb_lib::server::get::Client::new(BufReader::new(Box::new(
TcpStream::connect(addr).expect("opening get client connection"), TcpStream::connect(addr).expect("opening get client connection"),
) ) as _))
as _))
.expect("initializing get client connection"), .expect("initializing get client connection"),
)); ));
'anotherifstatement: { #[allow(unused_labels)]
#[cfg(feature = "playback")] 'anotherifstatement: {
if let Mode::GuiSyncplayerLocal { lib_dir } = mode { #[cfg(feature = "playback")]
database.lock().unwrap().lib_directory = lib_dir; if let Mode::GuiSyncplayerLocal { lib_dir } = mode {
break 'anotherifstatement; database.lock().unwrap().lib_directory = lib_dir;
} break 'anotherifstatement;
#[cfg(feature = "playback")]
if let Mode::GuiSyncplayerNetwork = mode {
break 'anotherifstatement;
}
// if not using syncplayer-local
database.lock().unwrap().remote_server_as_song_file_source =
Some(Arc::clone(&get_con));
} }
let occasional_refresh_sender = Arc::clone(&sender); #[cfg(feature = "playback")]
thread::spawn(move || loop { if let Mode::GuiSyncplayerNetwork = mode {
std::thread::sleep(std::time::Duration::from_secs(1)); break 'anotherifstatement;
if let Some(v) = &*occasional_refresh_sender.lock().unwrap() { }
v.send_event(GuiEvent::Refresh).unwrap(); // if not using syncplayer-local
} database.lock().unwrap().remote_server_as_song_file_source =
}); Some(Arc::clone(&get_con));
gui::main( }
database, let occasional_refresh_sender = Arc::clone(&sender);
con, thread::spawn(move || loop {
get_con, std::thread::sleep(std::time::Duration::from_secs(1));
sender, if let Some(v) = &*occasional_refresh_sender.lock().unwrap() {
#[cfg(feature = "merscfg")] v.send_event(GuiEvent::Refresh).unwrap();
&mers_after_db_updated_action, }
) });
}; gui::main(
} database,
con,
get_con,
sender,
#[cfg(feature = "merscfg")]
&mers_after_db_updated_action,
)
}};
}
match mode {
#[cfg(feature = "speedy2d")]
#[cfg(feature = "playback")]
Mode::Gui | Mode::GuiSyncplayerLocal { .. } | Mode::GuiSyncplayerNetwork => gui_modes!(),
#[cfg(feature = "speedy2d")]
#[cfg(not(feature = "playback"))]
Mode::Gui => gui_modes!(),
#[cfg(feature = "playback")] #[cfg(feature = "playback")]
Mode::SyncplayerLocal { .. } | Mode::SyncplayerNetwork => { Mode::SyncplayerLocal { .. } | Mode::SyncplayerNetwork => {
con_thread.join().unwrap(); con_thread.join().unwrap();