1
0
mirror of https://gitlab.com/OpenMW/openmw.git synced 2025-01-07 03:54:40 +00:00

Workaround per-frame resources leak in MyGUI. New vertex buffers were being created every frame.

This commit is contained in:
scrawl 2014-06-13 19:06:09 +02:00
parent e458cf1df2
commit 8114f48469
2 changed files with 32 additions and 2 deletions

View File

@ -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;
}

View File

@ -42,6 +42,9 @@ namespace MWGui
MyGUI::ImageBox* mItem;
MyGUI::ImageBox* mFrame;
std::string mCurrentItemTexture;
std::string mCurrentFrameTexture;
};
}