1
0
mirror of https://gitlab.com/OpenMW/openmw.git synced 2025-02-10 21:40:15 +00:00

Handle MyGUI exceptions inside destructors

This commit is contained in:
Andrei Kortunov 2018-09-09 16:06:25 +04:00
parent aca6625af4
commit c2c24a76a4
5 changed files with 71 additions and 26 deletions

View File

@ -6,6 +6,8 @@
#include <MyGUI_Gui.h> #include <MyGUI_Gui.h>
#include <MyGUI_Window.h> #include <MyGUI_Window.h>
#include <components/debug/debuglog.hpp>
#include "../mwbase/windowmanager.hpp" #include "../mwbase/windowmanager.hpp"
#include "../mwbase/environment.hpp" #include "../mwbase/environment.hpp"
@ -48,9 +50,16 @@ KeyboardNavigation::KeyboardNavigation()
} }
KeyboardNavigation::~KeyboardNavigation() KeyboardNavigation::~KeyboardNavigation()
{
try
{ {
MyGUI::WidgetManager::getInstance().unregisterUnlinker(this); MyGUI::WidgetManager::getInstance().unregisterUnlinker(this);
} }
catch(const MyGUI::Exception& e)
{
Log(Debug::Error) << "Error in the destructor: " << e.what();
}
}
void KeyboardNavigation::saveFocus(int mode) void KeyboardNavigation::saveFocus(int mode)
{ {

View File

@ -5,6 +5,8 @@
#include <MyGUI_WidgetDefines.h> #include <MyGUI_WidgetDefines.h>
#include <MyGUI_Widget.h> #include <MyGUI_Widget.h>
#include <components/debug/debuglog.hpp>
namespace MWGui namespace MWGui
{ {
/** The Layout class is an utility class used to load MyGUI layouts /** The Layout class is an utility class used to load MyGUI layouts
@ -16,7 +18,17 @@ namespace MWGui
Layout(const std::string & _layout, MyGUI::Widget* _parent = nullptr) Layout(const std::string & _layout, MyGUI::Widget* _parent = nullptr)
: mMainWidget(nullptr) : mMainWidget(nullptr)
{ initialise(_layout, _parent); } { initialise(_layout, _parent); }
virtual ~Layout() { shutdown(); } virtual ~Layout()
{
try
{
shutdown();
}
catch(const MyGUI::Exception& e)
{
Log(Debug::Error) << "Error in the destructor: " << e.what();
}
}
MyGUI::Widget* getWidget(const std::string& _name); MyGUI::Widget* getWidget(const std::string& _name);

View File

@ -98,9 +98,16 @@ namespace MWGui
} }
ScreenFader::~ScreenFader() ScreenFader::~ScreenFader()
{
try
{ {
MyGUI::Gui::getInstance().eventFrameStart -= MyGUI::newDelegate(this, &ScreenFader::onFrameStart); MyGUI::Gui::getInstance().eventFrameStart -= MyGUI::newDelegate(this, &ScreenFader::onFrameStart);
} }
catch(const MyGUI::Exception& e)
{
Log(Debug::Error) << "Error in the destructor: " << e.what();
}
}
void ScreenFader::onFrameStart(float dt) void ScreenFader::onFrameStart(float dt)
{ {

View File

@ -517,6 +517,8 @@ namespace MWGui
} }
WindowManager::~WindowManager() WindowManager::~WindowManager()
{
try
{ {
mKeyboardNavigation.reset(); mKeyboardNavigation.reset();
@ -548,6 +550,11 @@ namespace MWGui
mGuiPlatform->shutdown(); mGuiPlatform->shutdown();
delete mGuiPlatform; delete mGuiPlatform;
} }
catch(const MyGUI::Exception& e)
{
Log(Debug::Error) << "Error in the destructor: " << e.what();
}
}
void WindowManager::setStore(const MWWorld::ESMStore &store) void WindowManager::setStore(const MWWorld::ESMStore &store)
{ {

View File

@ -161,7 +161,17 @@ namespace Gui
mTextures.clear(); mTextures.clear();
for (std::vector<MyGUI::ResourceManualFont*>::iterator it = mFonts.begin(); it != mFonts.end(); ++it) for (std::vector<MyGUI::ResourceManualFont*>::iterator it = mFonts.begin(); it != mFonts.end(); ++it)
{
try
{
MyGUI::ResourceManager::getInstance().removeByName((*it)->getResourceName()); MyGUI::ResourceManager::getInstance().removeByName((*it)->getResourceName());
}
catch(const MyGUI::Exception& e)
{
Log(Debug::Error) << "Error in the destructor: " << e.what();
}
}
mFonts.clear(); mFonts.clear();
} }