diff --git a/src/vkcv/WindowManager.cpp b/src/vkcv/WindowManager.cpp index 48eab2767205e69c695b6021dcbb351032321f47..3179b219e9e93905d7202cf8e11dbbf0e019020f 100644 --- a/src/vkcv/WindowManager.cpp +++ b/src/vkcv/WindowManager.cpp @@ -26,8 +26,9 @@ namespace vkcv { SwapchainHandle swapchainHandle = swapchainManager.createSwapchain(*window); if (resizeable) { - const event_handle<int, int> &resizeHandle = window->e_resize.add([&](int width, int height) { - swapchainManager.signalRecreation(swapchainHandle); + const event_handle<int, int> &resizeHandle = window->e_resize.add([&,handle=swapchainHandle](int width, int height) { + // copy handle because it would run out of scope and be invalid + swapchainManager.signalRecreation(handle); }); window->m_resizeHandle = resizeHandle; }