ItemWidget: skip setImageTexture if the icon has not changed

coverity_scan^2
scrawl 8 years ago
parent 5f2539adb6
commit 7201cf5fe2

@ -67,20 +67,30 @@ namespace MWGui
void ItemWidget::setIcon(const std::string &icon) void ItemWidget::setIcon(const std::string &icon)
{ {
if (mItemShadow) if (mCurrentIcon != icon)
mItemShadow->setImageTexture(icon); {
if (mItem) mCurrentIcon = icon;
mItem->setImageTexture(icon);
if (mItemShadow)
mItemShadow->setImageTexture(icon);
if (mItem)
mItem->setImageTexture(icon);
}
} }
void ItemWidget::setFrame(const std::string &frame, const MyGUI::IntCoord &coord) void ItemWidget::setFrame(const std::string &frame, const MyGUI::IntCoord &coord)
{ {
if (mFrame) if (mFrame)
{ {
mFrame->setImageTexture(frame);
mFrame->setImageTile(MyGUI::IntSize(coord.width, coord.height)); // Why is this needed? MyGUI bug? mFrame->setImageTile(MyGUI::IntSize(coord.width, coord.height)); // Why is this needed? MyGUI bug?
mFrame->setImageCoord(coord); mFrame->setImageCoord(coord);
} }
if (mCurrentFrame != frame)
{
mCurrentFrame = frame;
mFrame->setImageTexture(frame);
}
} }
void ItemWidget::setIcon(const MWWorld::Ptr &ptr) void ItemWidget::setIcon(const MWWorld::Ptr &ptr)
@ -105,6 +115,8 @@ namespace MWGui
mItemShadow->setImageTexture(""); mItemShadow->setImageTexture("");
mItem->setImageTexture(""); mItem->setImageTexture("");
mText->setCaption(""); mText->setCaption("");
mCurrentIcon.clear();
mCurrentFrame.clear();
return; return;
} }

@ -47,6 +47,9 @@ namespace MWGui
MyGUI::ImageBox* mItemShadow; MyGUI::ImageBox* mItemShadow;
MyGUI::ImageBox* mFrame; MyGUI::ImageBox* mFrame;
MyGUI::TextBox* mText; MyGUI::TextBox* mText;
std::string mCurrentIcon;
std::string mCurrentFrame;
}; };
} }

Loading…
Cancel
Save