Add explicit disposed check to async bitmap load

This commit is contained in:
Varun Patil 2019-05-08 20:12:52 +05:30
parent f9c9cb5bca
commit bbe9976740
1 changed files with 6 additions and 4 deletions

View File

@ -63,12 +63,14 @@
void reloadBitmap(void * arg) {
emscripten_fetch_t * fetch = (emscripten_fetch_t *) arg;
try {
SDL_Surface * imgSurf = IMG_LoadTyped_RW(SDL_RWFromConstMem(fetch->data, fetch->numBytes), 1, "");
Bitmap * bitmap = ((Bitmap*)fetch->userData);
if (!bitmap->isDisposed()) {
SDL_Surface * imgSurf = IMG_LoadTyped_RW(SDL_RWFromConstMem(fetch->data, fetch->numBytes), 1, "");
bitmap->fromSurf(imgSurf, fetch->url);
if (bitmap->reloadCallback)
bitmap->reloadCallback(bitmap->reloadCallbackData);
}
} catch (const Exception &e) {}
emscripten_fetch_close(fetch);
}