fix: tokio rt is not set when calling handlers (#4850)
This commit is contained in:
1 parent
c3ff0c0ab3
commit
9f0bacc85c
1 file changed
+23
-2
@@ -261,7 +261,14 @@ impl WebviewInstance {
|
|||||||
asset_handlers,
|
asset_handlers,
|
||||||
edits
|
edits
|
||||||
];
|
];
|
||||||
|
|
||||||
|
#[cfg(feature = "tokio_runtime")]
|
||||||
|
let tokio_rt = tokio::runtime::Handle::current();
|
||||||
|
|
||||||
move |_id: WebViewId, request, responder: RequestAsyncResponder| {
|
move |_id: WebViewId, request, responder: RequestAsyncResponder| {
|
||||||
|
#[cfg(feature = "tokio_runtime")]
|
||||||
|
let _guard = tokio_rt.enter();
|
||||||
|
|
||||||
protocol::desktop_handler(
|
protocol::desktop_handler(
|
||||||
request,
|
request,
|
||||||
asset_handlers.clone(),
|
asset_handlers.clone(),
|
||||||
@@ -382,11 +389,25 @@ impl WebviewInstance {
|
|||||||
}
|
}
|
||||||
|
|
||||||
for (name, handler) in cfg.protocols.drain(..) {
|
for (name, handler) in cfg.protocols.drain(..) {
|
||||||
webview = webview.with_custom_protocol(name, handler);
|
#[cfg(feature = "tokio_runtime")]
|
||||||
|
let tokio_rt = tokio::runtime::Handle::current();
|
||||||
|
|
||||||
|
webview = webview.with_custom_protocol(name, move |a, b| {
|
||||||
|
#[cfg(feature = "tokio_runtime")]
|
||||||
|
let _guard = tokio_rt.enter();
|
||||||
|
handler(a, b)
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
for (name, handler) in cfg.asynchronous_protocols.drain(..) {
|
for (name, handler) in cfg.asynchronous_protocols.drain(..) {
|
||||||
webview = webview.with_asynchronous_custom_protocol(name, handler);
|
#[cfg(feature = "tokio_runtime")]
|
||||||
|
let tokio_rt = tokio::runtime::Handle::current();
|
||||||
|
|
||||||
|
webview = webview.with_asynchronous_custom_protocol(name, move |a, b, c| {
|
||||||
|
#[cfg(feature = "tokio_runtime")]
|
||||||
|
let _guard = tokio_rt.enter();
|
||||||
|
handler(a, b, c)
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
const INITIALIZATION_SCRIPT: &str = r#"
|
const INITIALIZATION_SCRIPT: &str = r#"
|
||||||
|
|||||||
Reference in new issue
Block a user