From ac341472d62d25d7c0e3fc968517ab8b547ec806 Mon Sep 17 00:00:00 2001 From: cutealien Date: Fri, 15 Mar 2024 14:52:22 +0000 Subject: [PATCH] Add error checks and log warnings in CIrrDeviceWin32::CCursorControl::addIcon git-svn-id: svn://svn.code.sf.net/p/irrlicht/code/trunk@6601 dfc29bdd-3216-0410-991c-e03cc46cb475 --- source/Irrlicht/CIrrDeviceWin32.cpp | 24 +++++++++++++++++++++--- 1 file changed, 21 insertions(+), 3 deletions(-) diff --git a/source/Irrlicht/CIrrDeviceWin32.cpp b/source/Irrlicht/CIrrDeviceWin32.cpp index 29dcdf91..f87b4451 100644 --- a/source/Irrlicht/CIrrDeviceWin32.cpp +++ b/source/Irrlicht/CIrrDeviceWin32.cpp @@ -2135,11 +2135,29 @@ gui::ECURSOR_ICON CIrrDeviceWin32::CCursorControl::addIcon(const gui::SCursorSpr irr::core::rect rectIcon = icon.SpriteBank->getPositions()[rectId]; HCURSOR hc = Device->TextureToCursor(HWnd, icon.SpriteBank->getTexture(texId), rectIcon, icon.HotSpot); - cW32.Frames.push_back( CursorFrameW32(hc) ); + if ( hc != NULL ) + { + cW32.Frames.push_back( CursorFrameW32(hc) ); + } + else + { + core::stringc warning("addIcon could not convert texture to cursor for frame "); + warning += core::stringc(i); + warning += " error "; + warning += core::stringc(GetLastError()); + os::Printer::log(warning.c_str(), ELL_WARNING); + } } - Cursors.push_back( cW32 ); - return (gui::ECURSOR_ICON)(Cursors.size() - 1); + if ( !cW32.Frames.empty() ) + { + Cursors.push_back( cW32 ); + return (gui::ECURSOR_ICON)(Cursors.size() - 1); + } + else + { + os::Printer::log("addIcon failed due to the lack of cursor frames", ELL_WARNING); + } } return gui::ECI_NORMAL; }