fix hot reload on windows (#2142)

This commit is contained in:
Evan Almloff authored and GitHub committed 2024-03-26 00:36:11 -07:00
1 parent 9942c8bfd1
commit e464294c66
5 files changed
+84 -51

No files matched your search

+18 -14
View File
@@ -474,22 +474,26 @@ impl App {
/// Whenever sigkill is sent, we shut down the app and save the window state
#[cfg(debug_assertions)]
fn connect_preserve_window_state_handler(&self) {
// Wire up the trap
let target = self.shared.proxy.clone();
std::thread::spawn(move || {
use signal_hook::consts::{SIGINT, SIGTERM};
let sigkill = signal_hook::iterator::Signals::new([SIGTERM, SIGINT]);
if let Ok(mut sigkill) = sigkill {
for _ in sigkill.forever() {
if target.send_event(UserWindowEvent::Shutdown).is_err() {
std::process::exit(0);
}
// TODO: make this work on windows
#[cfg(unix)]
{
// Wire up the trap
let target = self.shared.proxy.clone();
std::thread::spawn(move || {
use signal_hook::consts::{SIGINT, SIGTERM};
let sigkill = signal_hook::iterator::Signals::new([SIGTERM, SIGINT]);
if let Ok(mut sigkill) = sigkill {
for _ in sigkill.forever() {
if target.send_event(UserWindowEvent::Shutdown).is_err() {
std::process::exit(0);
}
// give it a moment for the event to be processed
std::thread::sleep(std::time::Duration::from_secs(1));
// give it a moment for the event to be processed
std::thread::sleep(std::time::Duration::from_secs(1));
}
}
}
});
});
}
}
}