@@ -67,30 +67,6 @@ Measure::Measure() : rm(nullptr), skin(nullptr), skinWindow(nullptr),
6767// Measure destructor
6868Measure::~Measure ()
6969{
70- // Proper cleanup sequence to prevent crashes
71-
72- // 1. Remove event handlers first
73- if (webView && webMessageToken.value != 0 )
74- {
75- webView->remove_WebMessageReceived (webMessageToken);
76- webMessageToken = {};
77- }
78-
79- // 2. Close and release WebView2 controller
80- if (webViewController)
81- {
82- webViewController->Close ();
83- webViewController.reset (); // Explicit release
84- }
85-
86- // 3. Release WebView COM pointer
87- if (webView)
88- {
89- webView.reset (); // Explicit release
90- }
91-
92- // 4. Brief delay to allow async cleanup
93- Sleep (100 );
9470}
9571
9672// Rainmeter Plugin Exports
@@ -155,38 +131,9 @@ PLUGIN_EXPORT void Reload(void* data, void* rm, double* maxValue)
155131 // Read visibility
156132 measure->visible = RmReadInt (rm, L" Visible" , 1 ) != 0 ;
157133
158- // Create WebView2 if not already created
159- if (!measure->initialized )
160- {
161- CreateWebView2 (measure);
162- }
163- else
164- {
165- // Update existing WebView
166- if (measure->webView && !measure->url .empty ())
167- {
168- measure->webView ->Navigate (measure->url .c_str ());
169- }
170-
171- // Update WebView2 bounds
172- if (measure->webViewController )
173- {
174- RECT bounds;
175- GetClientRect (measure->skinWindow , &bounds);
176- bounds.left = measure->x ;
177- bounds.top = measure->y ;
178- if (measure->width > 0 )
179- {
180- bounds.right = measure->x + measure->width ;
181- }
182- if (measure->height > 0 )
183- {
184- bounds.bottom = measure->y + measure->height ;
185- }
186- measure->webViewController ->put_Bounds (bounds);
187- measure->webViewController ->put_IsVisible (measure->visible ? TRUE : FALSE );
188- }
189- }
134+ // Always create fresh WebView2 instance on every Reload
135+ // This matches the stable PluginWebView-main pattern and prevents race conditions
136+ CreateWebView2 (measure);
190137}
191138
192139PLUGIN_EXPORT double Update (void * data)
0 commit comments