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: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/41299>
This commit is contained in:
Emma Anholt 2026-04-23 15:33:59 -07:00 committed by Marge Bot
parent a2f4977e7f
commit 0fc106823c

View file

@ -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 )