diff --git a/doomsday/client/src/ui/widgets/logwidget.cpp b/doomsday/client/src/ui/widgets/logwidget.cpp index 0485e3c015..10c1939f58 100644 --- a/doomsday/client/src/ui/widgets/logwidget.cpp +++ b/doomsday/client/src/ui/widgets/logwidget.cpp @@ -42,6 +42,7 @@ using namespace ui; DENG2_PIMPL(LogWidget), DENG2_OBSERVES(Atlas, Reposition), +DENG2_OBSERVES(Atlas, OutOfSpace), public Font::RichFormat::IStyle { typedef GLBufferT VertexBuf; @@ -491,7 +492,9 @@ public Font::RichFormat::IStyle entryAtlas = AtlasTexture::newWithRowAllocator( Atlas::BackingStore | Atlas::AllowDefragment, GLTexture::maximumSize().min(Atlas::Size(2048, 1024))); + entryAtlas->audienceForReposition += this; + entryAtlas->audienceForOutOfSpace += this; // Simple texture for the scroll indicator. Image solidWhitePixel = Image::solidColor(Image::Color(255, 255, 255, 255), @@ -535,6 +538,15 @@ public Font::RichFormat::IStyle } } + void atlasOutOfSpace(Atlas &atlas) + { + if(entryAtlas == &atlas) + { + entryAtlasLayoutChanged = true; + releaseAllComposedEntries(); + } + } + duint contentWidth() const { return self.viewportSize().x; @@ -620,6 +632,17 @@ public Font::RichFormat::IStyle } } + /** + * Releases all entries currently stored in the entry atlas. + */ + void releaseAllComposedEntries() + { + for(int i = 0; i < cache.size(); ++i) + { + cache[i]->clear(); + } + } + /** * Removes entries from the sink and the cache. */ @@ -711,17 +734,20 @@ public Font::RichFormat::IStyle } visibleRange.start = idx; } - } - if(entryAtlasLayoutChanged) - { - // Oops, the atlas was optimized during the loop and some items' - // positions are obsolete. - verts.clear(); - continue; + if(entryAtlasLayoutChanged) + { + goto nextAttempt; + } } + // Successfully completed. break; + +nextAttempt: + // Oops, the atlas was optimized during the loop and some items' + // positions are obsolete. + verts.clear(); } // Draw the scroll indicator, too.