1
0
mirror of https://gitlab.com/OpenMW/openmw.git synced 2025-02-10 12:39:53 +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"
@ -49,7 +51,14 @@ KeyboardNavigation::KeyboardNavigation()
KeyboardNavigation::~KeyboardNavigation() KeyboardNavigation::~KeyboardNavigation()
{ {
MyGUI::WidgetManager::getInstance().unregisterUnlinker(this); try
{
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

@ -99,7 +99,14 @@ namespace MWGui
ScreenFader::~ScreenFader() ScreenFader::~ScreenFader()
{ {
MyGUI::Gui::getInstance().eventFrameStart -= MyGUI::newDelegate(this, &ScreenFader::onFrameStart); try
{
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

@ -518,35 +518,42 @@ namespace MWGui
WindowManager::~WindowManager() WindowManager::~WindowManager()
{ {
mKeyboardNavigation.reset(); try
{
mKeyboardNavigation.reset();
MyGUI::LanguageManager::getInstance().eventRequestTag.clear(); MyGUI::LanguageManager::getInstance().eventRequestTag.clear();
MyGUI::PointerManager::getInstance().eventChangeMousePointer.clear(); MyGUI::PointerManager::getInstance().eventChangeMousePointer.clear();
MyGUI::InputManager::getInstance().eventChangeKeyFocus.clear(); MyGUI::InputManager::getInstance().eventChangeKeyFocus.clear();
MyGUI::ClipboardManager::getInstance().eventClipboardChanged.clear(); MyGUI::ClipboardManager::getInstance().eventClipboardChanged.clear();
MyGUI::ClipboardManager::getInstance().eventClipboardRequested.clear(); MyGUI::ClipboardManager::getInstance().eventClipboardRequested.clear();
for (WindowBase* window : mWindows) for (WindowBase* window : mWindows)
delete window; delete window;
mWindows.clear(); mWindows.clear();
delete mMessageBoxManager; delete mMessageBoxManager;
delete mLocalMapRender; delete mLocalMapRender;
delete mCharGen; delete mCharGen;
delete mDragAndDrop; delete mDragAndDrop;
delete mSoulgemDialog; delete mSoulgemDialog;
delete mCursorManager; delete mCursorManager;
delete mToolTips; delete mToolTips;
cleanupGarbage(); cleanupGarbage();
mFontLoader.reset(); mFontLoader.reset();
mGui->shutdown(); mGui->shutdown();
delete mGui; delete mGui;
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)
MyGUI::ResourceManager::getInstance().removeByName((*it)->getResourceName()); {
try
{
MyGUI::ResourceManager::getInstance().removeByName((*it)->getResourceName());
}
catch(const MyGUI::Exception& e)
{
Log(Debug::Error) << "Error in the destructor: " << e.what();
}
}
mFonts.clear(); mFonts.clear();
} }