Skip to content

Commit 2aa96c3

Browse files
committed
Dispose pChildVisual when CEOL being disposed
1 parent 79b7621 commit 2aa96c3

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

src/Files.App/ViewModels/UserControls/Previews/ShellPreviewViewModel.cs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ public sealed partial class ShellPreviewViewModel : BasePreviewModel
3737
WindowClass? wCls;
3838
HWND hwnd = HWND.NULL;
3939
bool isOfficePreview = false;
40+
ComPtr<IDCompositionVisual> pChildVisual = default;
4041

4142
[GeneratedComInterface, Guid("EACDD04C-117E-4E17-88F4-D1B12B0E3D89"), InterfaceType(ComInterfaceType.InterfaceIsIUnknown)]
4243
public partial interface IDCompositionTarget
@@ -168,7 +169,6 @@ private unsafe bool ChildWindowToXaml(nint parent, UIElement presenter)
168169
using ComPtr<IDXGIDevice> pDXGIDevice = default;
169170
using ComPtr<IDCompositionDevice> pDCompositionDevice = default;
170171
using ComPtr<IUnknown> pControlSurface = default;
171-
ComPtr<IDCompositionVisual> pChildVisual = default; // Don't dispose this one, it's used by the compositor
172172

173173
// Create the D3D11 device
174174
foreach (var driverType in driverTypes)
@@ -236,6 +236,8 @@ public void UnloadPreview()
236236
outputLink?.Dispose();
237237
outputLink = null;
238238

239+
pChildVisual.Dispose();
240+
239241
if (wCls is not null)
240242
UnregisterClass(wCls.ClassName, Kernel32.GetModuleHandle());
241243
}

0 commit comments

Comments
 (0)