Fix SDL_SetWindowIcon on singlethreaded Emscripten builds (#14850)

This commit is contained in:
ROllerozxa
2026-01-18 05:38:36 +01:00
committed by GitHub
parent 34b620c3f8
commit 064096bf61

View File

@@ -794,11 +794,9 @@ static bool Emscripten_SetWindowIcon(SDL_VideoDevice *_this, SDL_Window *window,
// Pass PNG data to JavaScript
MAIN_THREAD_EM_ASM({
var pngData = HEAPU8.subarray($0, $0 + $1);
if (pngData.buffer instanceof SharedArrayBuffer) {
// explicitly create a copy
pngData = new Uint8Array(pngData);
}
// Use `.slice` to make a copy of the data if we are dealing with a SharedArrayBuffer, or `.subarray` to create a
// view into the existing buffer if its non-shared.
var pngData = HEAPU8.buffer instanceof ArrayBuffer ? HEAPU8.subarray($0, $0 + $1) : HEAPU8.slice($0, $0 + $1);
var blob = new Blob([pngData], {type: 'image/png'});
var url = URL.createObjectURL(blob);