Skip to content

Commit

Permalink
Widgets|Fixed: Label images sometimes not initialized
Browse files Browse the repository at this point in the history
ProceduralImage instances were only GL-initialized if they were set before
the widget itself was initialized.
  • Loading branch information
skyjake committed Jan 21, 2017
1 parent 95abe8e commit a88c946
Show file tree
Hide file tree
Showing 5 changed files with 17 additions and 6 deletions.
Expand Up @@ -39,7 +39,7 @@ class LIBAPPFW_PUBLIC AtlasProceduralImage : public ProceduralImage
{
public:
AtlasProceduralImage(GuiWidget &owner)
: _owner(owner), _atlas(0), _needUpdate(false)
: _owner(owner), _atlas(0), _id(Id::None), _needUpdate(false)
{}

~AtlasProceduralImage()
Expand Down Expand Up @@ -71,6 +71,7 @@ class LIBAPPFW_PUBLIC AtlasProceduralImage : public ProceduralImage
{
_atlas->release(_id);
_atlas = 0;
_id = Id::None;
}
}

Expand All @@ -94,7 +95,10 @@ class LIBAPPFW_PUBLIC AtlasProceduralImage : public ProceduralImage

void glInit()
{
alloc();
if (_id.isNone())
{
alloc();
}
}

void glDeinit()
Expand Down
Expand Up @@ -59,7 +59,7 @@ class LIBAPPFW_PUBLIC ProceduralImage
*/
virtual bool update();

virtual void glInit();
virtual void glInit(); // called repeatedly
virtual void glDeinit();
virtual void glMakeGeometry(DefaultVertexBuf::Builder &verts, Rectanglef const &rect) = 0;

Expand Down
Expand Up @@ -71,7 +71,10 @@ class StyleProceduralImage : public ProceduralImage

void glInit()
{
alloc();
if (_id.isNone())
{
alloc();
}
}

void glDeinit()
Expand Down
3 changes: 2 additions & 1 deletion doomsday/sdk/libappfw/src/widgets/labelwidget.cpp
Expand Up @@ -607,7 +607,7 @@ void LabelWidget::setImage(Image const &image)
{
AtlasProceduralImage *proc = new AtlasProceduralImage(*this);
proc->setImage(image);
d->image.reset(proc);
setImage(proc);
}
else
{
Expand Down Expand Up @@ -798,6 +798,7 @@ void LabelWidget::update()

if (isInitialized())
{
if (d->image) d->image->glInit();
d->updateGeometry();
}
d->updateAppearanceAnimation();
Expand Down
5 changes: 4 additions & 1 deletion doomsday/sdk/libappfw/src/widgets/popupmenuwidget.cpp
Expand Up @@ -67,7 +67,10 @@ DENG_GUI_PIMPL(PopupMenuWidget)

void glInit()
{
alloc();
if (_id.isNone())
{
alloc();
}
}

void glDeinit()
Expand Down

0 comments on commit a88c946

Please sign in to comment.