From 630dcf4226cb5efb10a5a18f969db3c91a3cbc8f Mon Sep 17 00:00:00 2001 From: aoyako Date: Tue, 20 Feb 2024 19:32:40 +0900 Subject: [PATCH 1/3] fix: null bitmap pointer is passed when creating a texture resource --- librtt/Display/Rtt_TextureFactory.cpp | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/librtt/Display/Rtt_TextureFactory.cpp b/librtt/Display/Rtt_TextureFactory.cpp index 0271f72b9..6f6253495 100644 --- a/librtt/Display/Rtt_TextureFactory.cpp +++ b/librtt/Display/Rtt_TextureFactory.cpp @@ -277,7 +277,13 @@ TextureFactory::FindOrCreate( if ( result.IsNull() ) { PlatformBitmap *bitmap = CreateBitmap( filePath.GetString(), flags, isMask ); - result = CreateAndAdd( key, bitmap, true, isRetina ); + + if ( bitmap ) + { + result = CreateAndAdd( key, bitmap, true, isRetina ); + } else { + Rtt_ASSERT( result.IsNull() ); + } } return result; From 9af3d322462f6a6bf7b24d164782954596677641 Mon Sep 17 00:00:00 2001 From: aoyako Date: Wed, 21 Feb 2024 15:27:06 +0900 Subject: [PATCH 2/3] add: error message in the log when can't load bmp file --- platform/linux/src/Rtt_LinuxBitmap.cpp | 4 ++++ platform/shared/Rtt_BitmapUtils.cpp | 2 ++ 2 files changed, 6 insertions(+) diff --git a/platform/linux/src/Rtt_LinuxBitmap.cpp b/platform/linux/src/Rtt_LinuxBitmap.cpp index 0a2aa7807..3076d5ef4 100644 --- a/platform/linux/src/Rtt_LinuxBitmap.cpp +++ b/platform/linux/src/Rtt_LinuxBitmap.cpp @@ -125,6 +125,10 @@ namespace Rtt { fFormat = kRGBA; } + else + { + Rtt_LogException("Failed to load %s\n", path); + } } else if (ext == ".png") { diff --git a/platform/shared/Rtt_BitmapUtils.cpp b/platform/shared/Rtt_BitmapUtils.cpp index d4e9782a2..ad49ceae2 100644 --- a/platform/shared/Rtt_BitmapUtils.cpp +++ b/platform/shared/Rtt_BitmapUtils.cpp @@ -238,6 +238,8 @@ namespace bitmapUtil format = Rtt::PlatformBitmap::Format::kRGBA; return im; } + + return NULL; } // From 40381916305475b1a0849fa25cc917b3d1b4ab1b Mon Sep 17 00:00:00 2001 From: aoyako Date: Wed, 21 Feb 2024 15:37:29 +0900 Subject: [PATCH 3/3] add: error message in the log when can't load bmp file for emscripten --- platform/emscripten/Rtt_EmscriptenBitmap.cpp | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/platform/emscripten/Rtt_EmscriptenBitmap.cpp b/platform/emscripten/Rtt_EmscriptenBitmap.cpp index 5cd8597b9..58cbbbcde 100644 --- a/platform/emscripten/Rtt_EmscriptenBitmap.cpp +++ b/platform/emscripten/Rtt_EmscriptenBitmap.cpp @@ -186,6 +186,10 @@ namespace Rtt { fFormat = kRGBA; } + else + { + Rtt_LogException("Failed to load %s\n", path); + } } else if (ext == ".png")