Skip to content

Commit b46368e

Browse files
authored
Fix: Set correct hwnd for temporary webview2 controller (#3169)
* Fix: Set correct hwnd for temporary webview2 controller * Docs: #3169
1 parent e059e70 commit b46368e

File tree

2 files changed

+8
-2
lines changed

2 files changed

+8
-2
lines changed

Source/NETworkManager/ViewModels/WebConsoleSettingsViewModel.cs

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,10 @@
44
using NETworkManager.Settings;
55
using NETworkManager.Utilities;
66
using NETworkManager.Views;
7-
using System;
87
using System.Threading.Tasks;
98
using System.Windows;
109
using System.Windows.Input;
10+
using System.Windows.Interop;
1111

1212
namespace NETworkManager.ViewModels;
1313

@@ -118,7 +118,10 @@ private Task DeleteBrowsingData()
118118
// Create a temporary WebView2 instance to clear browsing data
119119
var webView2Environment =
120120
await CoreWebView2Environment.CreateAsync(null, GlobalStaticConfiguration.WebConsole_Cache);
121-
var webView2Controller = await webView2Environment.CreateCoreWebView2ControllerAsync(IntPtr.Zero);
121+
122+
var windowHwnd = new WindowInteropHelper(Application.Current.MainWindow).Handle;
123+
124+
var webView2Controller = await webView2Environment.CreateCoreWebView2ControllerAsync(windowHwnd);
122125

123126
await webView2Controller.CoreWebView2.Profile.ClearBrowsingDataAsync();
124127

Website/docs/changelog/next-release.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,9 @@ Release date: **xx.xx.2025**
3131

3232
## Bugfixes
3333

34+
- **Web Console**
35+
- Fixed an issue where clearing the Browser cache crashed the application. [#3169](https://github.com/BornToBeRoot/NETworkManager/pull/3169)
36+
3437
- **Profiles**
3538
- Fixed an issue where only one profile was deleted in `Settings > Profiles` when multiple profiles were selected. [#3144](https://github.com/BornToBeRoot/NETworkManager/pull/3144) [#3145](https://github.com/BornToBeRoot/NETworkManager/issues/3145)
3639

0 commit comments

Comments
 (0)