From 6ff4229f9b3ce7d303f78627091ab979946718c1 Mon Sep 17 00:00:00 2001 From: Jack Andersen Date: Mon, 28 May 2018 10:23:20 -1000 Subject: [PATCH] Windows deallocation fixes --- lib/graphicsdev/Vulkan.cpp | 1 + lib/win/ApplicationWin32.cpp | 12 +++++++++++- lib/win/WindowWin32.cpp | 4 ++-- test/main.cpp | 6 ++++-- 4 files changed, 18 insertions(+), 5 deletions(-) diff --git a/lib/graphicsdev/Vulkan.cpp b/lib/graphicsdev/Vulkan.cpp index 26742d9..dc6b57b 100644 --- a/lib/graphicsdev/Vulkan.cpp +++ b/lib/graphicsdev/Vulkan.cpp @@ -2786,6 +2786,7 @@ struct VulkanCommandQueue : IGraphicsCommandQueue m_running = false; if (m_submitted && vk::GetFenceStatus(m_ctx->m_dev, m_drawCompleteFence) == VK_NOT_READY) vk::WaitForFences(m_ctx->m_dev, 1, &m_drawCompleteFence, VK_FALSE, -1); + stallDynamicUpload(); static_cast(m_parent->getDataFactory())->DestroyGammaResources(); m_drawResTokens[0].clear(); m_drawResTokens[1].clear(); diff --git a/lib/win/ApplicationWin32.cpp b/lib/win/ApplicationWin32.cpp index 1af6c6e..e9f41f5 100644 --- a/lib/win/ApplicationWin32.cpp +++ b/lib/win/ApplicationWin32.cpp @@ -407,6 +407,13 @@ public: return clientReturn; } + ~ApplicationWin32() + { + for (auto& p : m_allWindows) + if (auto w = p.second.lock()) + w->_cleanup(); + } + SystemStringView getUniqueName() const { return m_uniqueName; @@ -506,7 +513,10 @@ int ApplicationRun(IApplication::EPlatformType platform, APP = new ApplicationWin32(cb, uniqueName, friendlyName, pname, args, gfxApi, samples, anisotropy, deepColor, singleInstance); - return APP->run(); + int ret = APP->run(); + delete APP; + APP = nullptr; + return ret; } } diff --git a/lib/win/WindowWin32.cpp b/lib/win/WindowWin32.cpp index e36b945..3e74cb6 100644 --- a/lib/win/WindowWin32.cpp +++ b/lib/win/WindowWin32.cpp @@ -1018,9 +1018,9 @@ public: m_gfxCtx.reset(new GraphicsContextWin32D3D(api, this, m_hwnd, b3dCtx)); } - ~WindowWin32() + void _cleanup() { - + m_gfxCtx.reset(); } void setCallback(IWindowCallback* cb) diff --git a/test/main.cpp b/test/main.cpp index 8428131..0b3aa73 100644 --- a/test/main.cpp +++ b/test/main.cpp @@ -613,7 +613,9 @@ int WINAPIV main(Platform::Array^ params) int APIENTRY wWinMain(HINSTANCE hInstance, HINSTANCE, LPWSTR lpCmdLine, int) { int argc = 0; - const boo::SystemChar** argv = (const wchar_t**)(CommandLineToArgvW(lpCmdLine, &argc)); + const boo::SystemChar** argv; + if (lpCmdLine[0]) + argv = (const wchar_t**)(CommandLineToArgvW(lpCmdLine, &argc)); static boo::SystemChar selfPath[1024]; GetModuleFileNameW(nullptr, selfPath, 1024); static const boo::SystemChar* booArgv[32] = {}; @@ -622,6 +624,6 @@ int APIENTRY wWinMain(HINSTANCE hInstance, HINSTANCE, LPWSTR lpCmdLine, int) booArgv[i+1] = argv[i]; logvisor::CreateWin32Console(); - return wmain(argc+1, booArgv); + return wmain(argc + 1, booArgv); } #endif