diff --git a/apps/openmw/mwgui/itemwidget.cpp b/apps/openmw/mwgui/itemwidget.cpp index a1ca5cb6c9..7c79f8027c 100644 --- a/apps/openmw/mwgui/itemwidget.cpp +++ b/apps/openmw/mwgui/itemwidget.cpp @@ -33,12 +33,26 @@ namespace MWGui void ItemWidget::setIcon(const std::string &icon) { + // HACK HACK HACK: Don't setImageTexture if it hasn't changed. + // There is a leak in MyGUI for each setImageTexture on the same widget. + // http://www.ogre3d.org/addonforums/viewtopic.php?f=17&t=30251 + if (mCurrentItemTexture == icon) + return; + + mCurrentItemTexture = icon; if (mItem) mItem->setImageTexture(icon); } void ItemWidget::setFrame(const std::string &frame, const MyGUI::IntCoord &coord) { + // HACK HACK HACK: Don't setImageTexture if it hasn't changed. + // There is a leak in MyGUI for each setImageTexture on the same widget. + // http://www.ogre3d.org/addonforums/viewtopic.php?f=17&t=30251 + if (mCurrentFrameTexture == frame) + return; + + mCurrentFrameTexture = frame; if (mFrame) { mFrame->setImageTexture(frame); @@ -69,8 +83,21 @@ namespace MWGui if (ptr.isEmpty()) { if (mFrame) - mFrame->setImageTexture(""); - mItem->setImageTexture(""); + { + // HACK HACK HACK: Don't setImageTexture if it hasn't changed. + // There is a leak in MyGUI for each setImageTexture on the same widget. + // http://www.ogre3d.org/addonforums/viewtopic.php?f=17&t=30251 + if (!mCurrentFrameTexture.empty()) + { + mFrame->setImageTexture(""); + mCurrentFrameTexture = ""; + } + } + if (!mCurrentItemTexture.empty()) + { + mCurrentItemTexture = ""; + mItem->setImageTexture(""); + } return; } diff --git a/apps/openmw/mwgui/itemwidget.hpp b/apps/openmw/mwgui/itemwidget.hpp index 3de98489d0..5cdf712126 100644 --- a/apps/openmw/mwgui/itemwidget.hpp +++ b/apps/openmw/mwgui/itemwidget.hpp @@ -42,6 +42,9 @@ namespace MWGui MyGUI::ImageBox* mItem; MyGUI::ImageBox* mFrame; + + std::string mCurrentItemTexture; + std::string mCurrentFrameTexture; }; }