diff --git a/source/Irrlicht/CIrrDeviceSDL.cpp b/source/Irrlicht/CIrrDeviceSDL.cpp index 0ed8864c..93bd1d1d 100644 --- a/source/Irrlicht/CIrrDeviceSDL.cpp +++ b/source/Irrlicht/CIrrDeviceSDL.cpp @@ -219,29 +219,22 @@ void CIrrDeviceSDL::resetReceiveTextInputEvents() { gui::IGUIElement *elem = GUIEnvironment->getFocus(); if (elem && elem->acceptsIME()) { - core::rect *pos = new core::rect(elem->getAbsolutePosition()); - if (lastElemPos == NULL || *lastElemPos != *pos) + core::rect pos = elem->getAbsolutePosition(); + if (!lastElemPos || *lastElemPos != pos) { - if (lastElemPos != NULL) - delete lastElemPos; lastElemPos = pos; SDL_Rect rect; - rect.x = pos->UpperLeftCorner.X; - rect.y = pos->UpperLeftCorner.Y; - rect.w = pos->getWidth(); - rect.h = pos->getHeight(); + rect.x = pos.UpperLeftCorner.X; + rect.y = pos.UpperLeftCorner.Y; + rect.w = pos.getWidth(); + rect.h = pos.getHeight(); SDL_SetTextInputRect(&rect); SDL_StartTextInput(); } - else - { - delete pos; - } } else { - delete lastElemPos; - lastElemPos = NULL; + lastElemPos.reset(); SDL_StopTextInput(); } } @@ -322,8 +315,6 @@ CIrrDeviceSDL::CIrrDeviceSDL(const SIrrlichtCreationParameters& param) createGUIAndScene(); VideoDriver->OnResize(core::dimension2d(Width, Height)); } - - lastElemPos = NULL; } @@ -337,9 +328,6 @@ CIrrDeviceSDL::~CIrrDeviceSDL() for (u32 i=0; i #include +#include namespace irr { @@ -303,7 +304,7 @@ namespace irr bool Resizable; - core::rect *lastElemPos; + std::optional> lastElemPos; struct SKeyMap {