fix hot reload on windows (#2142)
This commit is contained in:
1 parent
9942c8bfd1
commit
e464294c66
5 files changed
+84
-51
No files matched your search
@@ -49,6 +49,8 @@ futures-util = { workspace = true }
|
||||
urlencoding = "2.1.2"
|
||||
async-trait = "0.1.68"
|
||||
tao = { version = "0.26.1", features = ["rwh_05"] }
|
||||
|
||||
[target.'cfg(unix)'.dependencies]
|
||||
signal-hook = "0.3.17"
|
||||
|
||||
[target.'cfg(any(target_os = "windows",target_os = "macos",target_os = "linux",target_os = "dragonfly", target_os = "freebsd", target_os = "netbsd", target_os = "openbsd"))'.dependencies]
|
||||
|
||||
+18
-14
@@ -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));
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user