Fix exception from SVG WebView2

This commit is contained in:
ema
2025-07-01 03:10:33 +08:00
parent f1237aa86f
commit 2750cb75dd
2 changed files with 10 additions and 13 deletions

View File

@@ -80,16 +80,13 @@ public class MetaProvider
return new Size(w, h);
// fallback
try
{
using (var mi = new MagickImage())
{
using var mi = new MagickImage();
mi.Ping(_path);
w = (int)mi.Width;
h = (int)mi.Height;
}
}
catch
{
// There are always formats that MagickImage does not support

View File

@@ -44,12 +44,12 @@ public class SvgImagePanel : WebpagePanel
set
{
_objectForScripting = value;
Dispatcher.Invoke(async () =>
{
await _webView.EnsureCoreWebView2Async();
_webView.CoreWebView2.AddHostObjectToScript("external", value);
});
_webView?.EnsureCoreWebView2Async()
.ContinueWith(_ =>
_webView?.Dispatcher.Invoke(() =>
_webView?.CoreWebView2.AddHostObjectToScript("external", value)
)
);
}
}