[PreviewHandlers]Check for Disposed state when updating window bounds (#33373)

* Fixed Previewer production crash with an ObjectDisposedException

* Bumped MSBuildCacheCacheUniverse
This commit is contained in:
Ani
2024-06-16 17:32:33 +02:00
committed by GitHub
parent cdf5677eb9
commit deb6234d72

View File

@@ -120,6 +120,12 @@ namespace Common
/// </summary> /// </summary>
public void UpdateWindowBounds(IntPtr hwnd, Rectangle newBounds) public void UpdateWindowBounds(IntPtr hwnd, Rectangle newBounds)
{ {
if (this.Disposing || this.IsDisposed)
{
// For unclear reasons, this can be called when handling an error and the form has already been disposed.
return;
}
// We must set the WS_CHILD style to change the form to a control within the Explorer preview pane // We must set the WS_CHILD style to change the form to a control within the Explorer preview pane
int windowStyle = NativeMethods.GetWindowLong(Handle, gwlStyle); int windowStyle = NativeMethods.GetWindowLong(Handle, gwlStyle);
if ((windowStyle & wsChild) == 0) if ((windowStyle & wsChild) == 0)