From 0fc106823c2cc5acc368650739c4d1503e8df6cf Mon Sep 17 00:00:00 2001 From: Emma Anholt Date: Thu, 23 Apr 2026 15:33:59 -0700 Subject: [PATCH] screenshot-layer: Fix rename() to final png before the file is flushed. If the app exited before the thread was finished, then we might get an incomplete png at the final filename. Part-of: --- src/vulkan/screenshot-layer/screenshot.cpp | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/vulkan/screenshot-layer/screenshot.cpp b/src/vulkan/screenshot-layer/screenshot.cpp index 17a3a5ac38d..a8b9a43bd4b 100644 --- a/src/vulkan/screenshot-layer/screenshot.cpp +++ b/src/vulkan/screenshot-layer/screenshot.cpp @@ -859,6 +859,11 @@ void *writePNG(void *data) { png_write_end(png, NULL); // End image writing free(row_pointer); + // Close before renaming, to ensure the writes are flushed (in case of app + // exit without vkDestroyDevice() to join our thread). + fclose(file); + file = NULL; + // Rename file, indicating completion, client should be // checking for the final file exists. if (rename(tmpFilename, filename) != 0 )