Skip to content

Commit

Permalink
Fixed: Use of PathTreeIterator
Browse files Browse the repository at this point in the history
The purpose of the PathTreeIterator template is to avoid the need
to manually cast the node to the specialized tree node type. Now
iterating with the correct tree class, i.e., TextureScheme::Index.
  • Loading branch information
skyjake committed Dec 15, 2012
1 parent 1c76f8d commit 0f769da
Show file tree
Hide file tree
Showing 5 changed files with 25 additions and 24 deletions.
2 changes: 1 addition & 1 deletion doomsday/engine/src/gl/gl_texmanager.cpp
Expand Up @@ -3276,7 +3276,7 @@ void GL_ReleaseTexturesByScheme(char const *schemeName)
PathTreeIterator<Textures::Scheme::Index> iter(App_Textures()->scheme(schemeName).index().leafNodes());
while(iter.hasNext())
{
TextureManifest &manifest = static_cast<TextureManifest &>(iter.next());
TextureManifest &manifest = iter.next();
GL_ReleaseGLTexturesByTexture(reinterpret_cast<texture_s *>(manifest.texture()));
}
}
Expand Down
4 changes: 2 additions & 2 deletions doomsday/engine/src/render/r_things.cpp
Expand Up @@ -244,10 +244,10 @@ static void buildSprites()
spriteRecordBlockSet = BlockSet_New(sizeof(spriterecord_t), 64),
spriteRecordFrameBlockSet = BlockSet_New(sizeof(spriterecord_frame_t), 256);

de::PathTreeIterator<de::PathTree> iter(App_Textures()->scheme("Sprites").index().leafNodes());
de::PathTreeIterator<de::TextureScheme::Index> iter(App_Textures()->scheme("Sprites").index().leafNodes());
while(iter.hasNext())
{
buildSprite(static_cast<de::TextureManifest &>(iter.next()));
buildSprite(iter.next());
}

LOG_INFO(de::String("buildSprites: Done in %1 seconds.").arg(begunAt.since(), 0, 'g', 2));
Expand Down
20 changes: 10 additions & 10 deletions doomsday/engine/src/resource/textures.cpp
Expand Up @@ -357,10 +357,10 @@ int Textures::iterate(String nameOfScheme,

if(!nameOfScheme.isEmpty())
{
PathTreeIterator<PathTree> iter(scheme(nameOfScheme).index().leafNodes());
PathTreeIterator<TextureScheme::Index> iter(scheme(nameOfScheme).index().leafNodes());
while(iter.hasNext())
{
TextureManifest &manifest = static_cast<TextureManifest &>(iter.next());
TextureManifest &manifest = iter.next();
if(!manifest.texture()) continue;

int result = callback(*manifest.texture(), parameters);
Expand All @@ -371,10 +371,10 @@ int Textures::iterate(String nameOfScheme,
{
DENG2_FOR_EACH_CONST(Schemes, i, d->schemes)
{
PathTreeIterator<PathTree> iter((*i)->index().leafNodes());
PathTreeIterator<TextureScheme::Index> iter((*i)->index().leafNodes());
while(iter.hasNext())
{
TextureManifest &manifest = static_cast<TextureManifest &>(iter.next());
TextureManifest &manifest = iter.next();
if(!manifest.texture()) continue;

int result = callback(*manifest.texture(), parameters);
Expand All @@ -392,10 +392,10 @@ int Textures::iterateDeclared(String nameOfScheme,

if(!nameOfScheme.isEmpty())
{
PathTreeIterator<PathTree> iter(scheme(nameOfScheme).index().leafNodes());
PathTreeIterator<TextureScheme::Index> iter(scheme(nameOfScheme).index().leafNodes());
while(iter.hasNext())
{
TextureManifest &manifest = static_cast<TextureManifest &>(iter.next());
TextureManifest &manifest = iter.next();
int result = callback(manifest, parameters);
if(result) return result;
}
Expand All @@ -404,10 +404,10 @@ int Textures::iterateDeclared(String nameOfScheme,
{
DENG2_FOR_EACH_CONST(Schemes, i, d->schemes)
{
PathTreeIterator<PathTree> iter((*i)->index().leafNodes());
PathTreeIterator<TextureScheme::Index> iter((*i)->index().leafNodes());
while(iter.hasNext())
{
TextureManifest &manifest = static_cast<TextureManifest &>(iter.next());
TextureManifest &manifest = iter.next();
int result = callback(manifest, parameters);
if(result) return result;
}
Expand Down Expand Up @@ -486,7 +486,7 @@ static QList<TextureManifest *> collectTextureManifests(Textures::Scheme *scheme
PathTreeIterator<Textures::Scheme::Index> iter(scheme->index().leafNodes());
while(iter.hasNext())
{
TextureManifest &manifest = static_cast<TextureManifest &>(iter.next());
TextureManifest &manifest = iter.next();
if(!path.isEmpty())
{
/// @todo Use PathTree::Node::compare()
Expand All @@ -512,7 +512,7 @@ static QList<TextureManifest *> collectTextureManifests(Textures::Scheme *scheme
PathTreeIterator<Textures::Scheme::Index> iter((*i)->index().leafNodes());
while(iter.hasNext())
{
TextureManifest &manifest = static_cast<TextureManifest &>(iter.next());
TextureManifest &manifest = iter.next();
if(!path.isEmpty())
{
/// @todo Use PathTree::Node::compare()
Expand Down
21 changes: 10 additions & 11 deletions doomsday/engine/src/resource/texturescheme.cpp
Expand Up @@ -46,10 +46,10 @@ struct TextureScheme::Instance
{
if(index_)
{
PathTreeIterator<PathTree> iter(index_->leafNodes());
PathTreeIterator<Index> iter(index_->leafNodes());
while(iter.hasNext())
{
TextureManifest &manifest = static_cast<TextureManifest &>(iter.next());
TextureManifest &manifest = iter.next();
deindex(manifest);
}
delete index_;
Expand All @@ -75,10 +75,10 @@ struct TextureScheme::Instance
if(minId) *minId = DDMAXINT;
if(maxId) *maxId = DDMININT;

PathTreeIterator<PathTree> iter(index_->leafNodes());
PathTreeIterator<Index> iter(index_->leafNodes());
while(iter.hasNext())
{
TextureManifest &manifest = static_cast<TextureManifest &>(iter.next());
TextureManifest &manifest = iter.next();
int const uniqueId = manifest.uniqueId();
if(minId && uniqueId < *minId) *minId = uniqueId;
if(maxId && uniqueId > *maxId) *maxId = uniqueId;
Expand Down Expand Up @@ -155,10 +155,10 @@ struct TextureScheme::Instance
if(lutSize)
{
// Populate the LUT.
PathTreeIterator<PathTree> iter(index_->leafNodes());
PathTreeIterator<Index> iter(index_->leafNodes());
while(iter.hasNext())
{
linkInUniqueIdLut(static_cast<TextureManifest &>(iter.next()));
linkInUniqueIdLut(iter.next());
}
}

Expand All @@ -180,11 +180,10 @@ void TextureScheme::clear()
{
if(d->index_)
{
PathTreeIterator<PathTree> iter(d->index_->leafNodes());
PathTreeIterator<Index> iter(d->index_->leafNodes());
while(iter.hasNext())
{
TextureManifest &manifest = static_cast<TextureManifest &>(iter.next());
d->deindex(manifest);
d->deindex(iter.next());
}
d->index_->clear();
d->uniqueIdLutDirty = true;
Expand Down Expand Up @@ -235,10 +234,10 @@ TextureManifest const &TextureScheme::findByResourceUri(Uri const &uri) const
{
if(!uri.isEmpty())
{
PathTreeIterator<PathTree> iter(d->index_->leafNodes());
PathTreeIterator<Index> iter(d->index_->leafNodes());
while(iter.hasNext())
{
TextureManifest &manifest = static_cast<TextureManifest &>(iter.next());
TextureManifest &manifest = iter.next();
if(manifest.resourceUri() == uri)
{
return manifest;
Expand Down
2 changes: 2 additions & 0 deletions doomsday/libdeng/src/garbage.cpp
Expand Up @@ -52,6 +52,8 @@ struct Garbage

void recycle()
{
DENG_ASSERT(!beingRecycled);

if(allocs.empty()) return;

beingRecycled = true;
Expand Down

0 comments on commit 0f769da

Please sign in to comment.