diff options
| author | Ian Elliott <ianelliott@google.com> | 2016-01-25 12:33:06 -0700 |
|---|---|---|
| committer | Jon Ashburn <jon@lunarg.com> | 2016-01-28 11:19:11 -0700 |
| commit | 0675b182376b0ecd51cff4e5c29bb03f2760807a (patch) | |
| tree | b3ae8b9e22ca71aa709c77afe267edb66d2b0867 | |
| parent | 22ababc340f8f08baefa4c02b9776a62474631e1 (diff) | |
| download | usermoji-0675b182376b0ecd51cff4e5c29bb03f2760807a.tar.xz | |
Swapchain: Ensure Destroy{Device|Surface}() don't core dump.
There are multiple pieces of code that can try to delete an SwpSwapchain struct:
- DestroyDevice()
- DestroySurface()
- DestroySwapchain()
This tries to address the various paths through the code, so that
Destroy{Device|Surface}() won't also try to destroy an already-destroyed
swapchain.
| -rw-r--r-- | layers/swapchain.cpp | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/layers/swapchain.cpp b/layers/swapchain.cpp index 47e4fe83..f16e4fa6 100644 --- a/layers/swapchain.cpp +++ b/layers/swapchain.cpp @@ -997,6 +997,13 @@ VK_LAYER_EXPORT VKAPI_ATTR void VKAPI_CALL vkDestroySurfaceKHR(VkInstance insta it != pSurface->swapchains.end() ; it++) { // Delete all SwpImage's it->second->images.clear(); + // In case the swapchain's device hasn't been destroyed yet + // (which isn't likely, but is possible), delete its + // association with this swapchain (i.e. so we can't point to + // this swpchain from that device, later on): + if (it->second->pDevice) { + it->second->pDevice->swapchains.clear(); + } } pSurface->swapchains.clear(); } @@ -1118,6 +1125,13 @@ VK_LAYER_EXPORT VKAPI_ATTR void VKAPI_CALL vkDestroyDevice(VkDevice device, cons it != pDevice->swapchains.end() ; it++) { // Delete all SwpImage's it->second->images.clear(); + // In case the swapchain's surface hasn't been destroyed yet + // (which is likely) delete its association with this swapchain + // (i.e. so we can't point to this swpchain from that surface, + // later on): + if (it->second->pSurface) { + it->second->pSurface->swapchains.clear(); + } } pDevice->swapchains.clear(); } @@ -1864,6 +1878,9 @@ VK_LAYER_EXPORT VKAPI_ATTR void VKAPI_CALL vkDestroySwapchainKHR( __FUNCTION__); } } + if (pSwapchain->pSurface) { + pSwapchain->pSurface->swapchains.erase(swapchain); + } if (pSwapchain->imageCount) { pSwapchain->images.clear(); } |
