mirror of
https://github.com/feschber/lan-mouse.git
synced 2026-04-21 05:23:18 +03:00
panic if dropped without being terminated
This commit is contained in:
@@ -60,6 +60,7 @@ pub struct LibeiInputCapture<'a> {
|
|||||||
notify_capture: Sender<LibeiNotifyEvent>,
|
notify_capture: Sender<LibeiNotifyEvent>,
|
||||||
notify_release: Arc<Notify>,
|
notify_release: Arc<Notify>,
|
||||||
cancellation_token: CancellationToken,
|
cancellation_token: CancellationToken,
|
||||||
|
terminated: bool,
|
||||||
}
|
}
|
||||||
|
|
||||||
static INTERFACES: Lazy<HashMap<&'static str, u32>> = Lazy::new(|| {
|
static INTERFACES: Lazy<HashMap<&'static str, u32>> = Lazy::new(|| {
|
||||||
@@ -222,6 +223,7 @@ impl<'a> LibeiInputCapture<'a> {
|
|||||||
notify_capture,
|
notify_capture,
|
||||||
notify_release,
|
notify_release,
|
||||||
cancellation_token,
|
cancellation_token,
|
||||||
|
terminated: false,
|
||||||
};
|
};
|
||||||
|
|
||||||
Ok(producer)
|
Ok(producer)
|
||||||
@@ -548,10 +550,19 @@ impl<'a> LanMouseInputCapture for LibeiInputCapture<'a> {
|
|||||||
log::debug!("waiting for capture to terminate...");
|
log::debug!("waiting for capture to terminate...");
|
||||||
let res = task.await.expect("libei task panic");
|
let res = task.await.expect("libei task panic");
|
||||||
log::debug!("done!");
|
log::debug!("done!");
|
||||||
|
self.terminated = true;
|
||||||
res
|
res
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
impl<'a> Drop for LibeiInputCapture<'a> {
|
||||||
|
fn drop(&mut self) {
|
||||||
|
if !self.terminated {
|
||||||
|
panic!("LibeiInputCapture dropped without being terminated!");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
impl<'a> Stream for LibeiInputCapture<'a> {
|
impl<'a> Stream for LibeiInputCapture<'a> {
|
||||||
type Item = Result<(CaptureHandle, Event), CaptureError>;
|
type Item = Result<(CaptureHandle, Event), CaptureError>;
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user