mirror of
https://github.com/Stremio/stremio-shell-ng.git
synced 2026-05-17 01:42:11 +00:00
fix: keep crash-restart off the GUI message-pump thread
Some checks failed
Continuous integration / test (push) Has been cancelled
Some checks failed
Continuous integration / test (push) Has been cancelled
This commit is contained in:
parent
27ef17042c
commit
508db3ff8b
1 changed files with 10 additions and 6 deletions
|
|
@ -78,13 +78,14 @@ pub struct StremioServer {
|
||||||
}
|
}
|
||||||
|
|
||||||
impl StremioServer {
|
impl StremioServer {
|
||||||
pub fn start(&self) {
|
/// Spawn the streaming server; recv on the returned receiver to wait for readiness.
|
||||||
|
pub fn start(&self) -> Option<flume::Receiver<String>> {
|
||||||
if self.development {
|
if self.development {
|
||||||
return;
|
return None;
|
||||||
}
|
}
|
||||||
if self.running.swap(true, Ordering::SeqCst) {
|
if self.running.swap(true, Ordering::SeqCst) {
|
||||||
eprintln!("StremioServer::start() called while a server is already running; skipping");
|
eprintln!("StremioServer::start() called while a server is already running; skipping");
|
||||||
return;
|
return None;
|
||||||
}
|
}
|
||||||
let (tx, rx) = flume::unbounded();
|
let (tx, rx) = flume::unbounded();
|
||||||
let logs = self.logs.clone();
|
let logs = self.logs.clone();
|
||||||
|
|
@ -220,8 +221,7 @@ impl StremioServer {
|
||||||
sender.notice();
|
sender.notice();
|
||||||
});
|
});
|
||||||
|
|
||||||
// Wait for the server to start
|
Some(rx)
|
||||||
rx.recv().unwrap();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -240,7 +240,10 @@ impl PartialUi for StremioServer {
|
||||||
.parent(data.parent)
|
.parent(data.parent)
|
||||||
.build(&mut data.crash_notice)
|
.build(&mut data.crash_notice)
|
||||||
.ok();
|
.ok();
|
||||||
data.start();
|
// Block until ready so the WebView isn't attached against an unbound port.
|
||||||
|
if let Some(rx) = data.start() {
|
||||||
|
rx.recv().ok();
|
||||||
|
}
|
||||||
println!("Stremio server started");
|
println!("Stremio server started");
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
@ -257,6 +260,7 @@ impl PartialUi for StremioServer {
|
||||||
"Stremio server crash log",
|
"Stremio server crash log",
|
||||||
self.logs.lock().unwrap().deref(),
|
self.logs.lock().unwrap().deref(),
|
||||||
);
|
);
|
||||||
|
// Don't block: this runs on the GUI message pump.
|
||||||
self.start();
|
self.start();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue