From 09e8e5f932f0027fa917ecfc167464c4880f789d Mon Sep 17 00:00:00 2001 From: Martin Date: Thu, 13 Jun 2024 17:00:29 +0200 Subject: [PATCH] [GLFW] Make IWindowInterop inherit from IDisposable --- .../Aardvark.Application.Slim.GL/Application.fs | 3 +-- .../Aardvark.Application.Slim.Vulkan/Application.fs | 3 +++ src/Application/Aardvark.Application.Slim/GLFW.fs | 7 ++----- 3 files changed, 6 insertions(+), 7 deletions(-) diff --git a/src/Application/Aardvark.Application.Slim.GL/Application.fs b/src/Application/Aardvark.Application.Slim.GL/Application.fs index e86e9bcac..3432689a0 100644 --- a/src/Application/Aardvark.Application.Slim.GL/Application.fs +++ b/src/Application/Aardvark.Application.Slim.GL/Application.fs @@ -343,8 +343,7 @@ module private OpenGL = glfw.WindowHint(WindowHintBool.ScaleToMonitor, true) glfw.WindowHint(WindowHintInt.Samples, if cfg.samples = 1 then 0 else cfg.samples) - interface IDisposable with - member x.Dispose() = cleanup() + override x.Dispose() = cleanup() } type OpenGlApplication private (runtime : Runtime, shaderCachePath : Option, hideCocoaMenuBar : bool) as this = diff --git a/src/Application/Aardvark.Application.Slim.Vulkan/Application.fs b/src/Application/Aardvark.Application.Slim.Vulkan/Application.fs index a55125720..568361816 100644 --- a/src/Application/Aardvark.Application.Slim.Vulkan/Application.fs +++ b/src/Application/Aardvark.Application.Slim.Vulkan/Application.fs @@ -93,6 +93,9 @@ module private Vulkan = override __.WindowHints(cfg: WindowConfig, glfw: Glfw) = glfw.WindowHint(WindowHintClientApi.ClientApi, ClientApi.NoApi) + + override __.Dispose() = + () } type VulkanApplication private (app : HeadlessVulkanApplication, hideCocoaMenuBar : bool) = diff --git a/src/Application/Aardvark.Application.Slim/GLFW.fs b/src/Application/Aardvark.Application.Slim/GLFW.fs index d30d30119..6aeaa4689 100644 --- a/src/Application/Aardvark.Application.Slim/GLFW.fs +++ b/src/Application/Aardvark.Application.Slim/GLFW.fs @@ -565,8 +565,8 @@ type IWindowSurface = abstract CreateSwapchain : V2i -> ISwapchain abstract Handle : obj -// TODO: Inherit IDisposable (see Instance.Dispose()) type IWindowInterop = + inherit IDisposable abstract Boot : Glfw -> unit abstract CreateSurface : IRuntime * WindowConfig * Glfw * nativeptr -> IWindowSurface abstract WindowHints : WindowConfig * Glfw -> unit @@ -753,10 +753,7 @@ type Instance(runtime : Aardvark.Rendering.IRuntime, interop : IWindowInterop, h if v then wait <- false member x.Dispose() = - match interop with - | :? IDisposable as d -> d.Dispose() - | _ -> () - + interop.Dispose() glfw.Terminate() interface IDisposable with