Skip to content

Commit

Permalink
Refactor|Fonts|Client: Moved linked-definition clearing from Fonts to…
Browse files Browse the repository at this point in the history
… ResourceSystem

It is no longer necessary to implement this logic with the resource
collection itself.
  • Loading branch information
danij-deng committed Nov 15, 2013
1 parent 6cd880b commit 6584f1c
Show file tree
Hide file tree
Showing 5 changed files with 19 additions and 17 deletions.
6 changes: 1 addition & 5 deletions doomsday/client/include/resource/fonts.h
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
#include <de/Error>
#include <de/Observers>
#include <de/String>
#include <QList>
#include <QMap>

/// Special value used to signify an invalid font id.
Expand Down Expand Up @@ -78,11 +79,6 @@ DENG2_OBSERVES(AbstractFont, Deletion)
*/
static void consoleRegister();

/**
* To be called during a definition database reset to clear all links to defs.
*/
void clearDefinitionLinks();

/**
* Returns the total number of unique fonts in the collection.
*/
Expand Down
6 changes: 6 additions & 0 deletions doomsday/client/include/resource/resourcesystem.h
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,12 @@ class ResourceSystem : public de::System
void clearRuntimeFontSchemes();
void clearSystemFontSchemes();

/**
* To be called during a definition database reset to clear all definitions
* linked to by Font resources.
*/
void clearFontDefinitionLinks();

AbstractFont *createFontFromDef(ded_compositefont_t const &def);
AbstractFont *createFontFromFile(de::Uri const &uri, de::String filePath);

Expand Down
2 changes: 1 addition & 1 deletion doomsday/client/src/def_main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1434,7 +1434,7 @@ void Def_Read()

invalidateAllMaterials();
#ifdef __CLIENT__
App_Fonts().clearDefinitionLinks();
App_ResourceSystem().clearFontDefinitionLinks();
#endif

Def_Destroy();
Expand Down
11 changes: 0 additions & 11 deletions doomsday/client/src/resource/fonts.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -214,17 +214,6 @@ Fonts::Manifest &Fonts::toManifest(fontid_t id) const
throw UnknownIdError("Fonts::toManifest", QString("Invalid font ID %1, valid range [1..%2)").arg(id).arg(d->manifestCount + 1));
}

void Fonts::clearDefinitionLinks()
{
foreach(AbstractFont *font, d->fonts)
{
if(CompositeBitmapFont *compFont = font->maybeAs<CompositeBitmapFont>())
{
compFont->setDefinition(0);
}
}
}

void Fonts::schemeManifestDefined(Scheme & /*scheme*/, Manifest &manifest)
{
// We want notification when the manifest is derived to produce a resource.
Expand Down
11 changes: 11 additions & 0 deletions doomsday/client/src/resource/resourcesystem.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -990,6 +990,17 @@ void ResourceSystem::clearSystemFontSchemes()
d->fonts.scheme("System").clear();
}

void ResourceSystem::clearFontDefinitionLinks()
{
foreach(AbstractFont *font, d->fonts.all())
{
if(CompositeBitmapFont *compFont = font->maybeAs<CompositeBitmapFont>())
{
compFont->setDefinition(0);
}
}
}

AbstractFont *ResourceSystem::createFontFromDef(ded_compositefont_t const &def)
{
LOG_AS("ResourceSystem::createFontFromDef");
Expand Down

0 comments on commit 6584f1c

Please sign in to comment.