Skip to content

Commit

Permalink
Fixed|PathDirectory: Failed assertion during abnormal shutdown
Browse files Browse the repository at this point in the history
  • Loading branch information
danij-deng committed Oct 19, 2012
1 parent d5206f1 commit ae2b0aa
Show file tree
Hide file tree
Showing 5 changed files with 57 additions and 25 deletions.
48 changes: 32 additions & 16 deletions doomsday/engine/portable/src/con_data.c
Expand Up @@ -186,6 +186,8 @@ static void clearVariables(void)
#else
int flags = PCF_NO_BRANCH;
#endif
if(!cvarDirectory) return;

PathDirectory_Iterate(cvarDirectory, flags, NULL, PATHDIRECTORY_NOHASH, clearVariable);
PathDirectory_Clear(cvarDirectory);
}
Expand Down Expand Up @@ -387,7 +389,10 @@ static void updateKnownWords(void)
countCVarParams.type = -1;
countCVarParams.hidden = false;
countCVarParams.ignoreHidden = true;
PathDirectory_Iterate2_Const(cvarDirectory, PCF_NO_BRANCH, NULL, PATHDIRECTORY_NOHASH, countVariable, &countCVarParams);
if(cvarDirectory)
{
PathDirectory_Iterate2_Const(cvarDirectory, PCF_NO_BRANCH, NULL, PATHDIRECTORY_NOHASH, countVariable, &countCVarParams);
}

// Build the known words table.
numKnownWords = numUniqueNamedCCmds + countCVarParams.count + numCAliases + GameCollection_Count(App_GameCollection());
Expand Down Expand Up @@ -1787,25 +1792,36 @@ D_CMD(ListVars)
#if _DEBUG
D_CMD(PrintVarStats)
{
cvartype_t type;
countvariableparams_t p;
uint numCVars = 0, numCVarsHidden = 0;

Con_FPrintf(CPF_YELLOW, "Console Variable Statistics:\n");
p.hidden = false;
p.ignoreHidden = false;
for(type = CVT_BYTE; type < CVARTYPE_COUNT; ++type)
if(cvarDirectory)
{
cvartype_t type;
countvariableparams_t p;
p.hidden = false;
p.ignoreHidden = false;
for(type = CVT_BYTE; type < CVARTYPE_COUNT; ++type)
{
p.count = 0;
p.type = type;
PathDirectory_Iterate2_Const(cvarDirectory, PCF_NO_BRANCH, NULL, PATHDIRECTORY_NOHASH, countVariable, &p);
Con_Printf("%12s: %u\n", Str_Text(CVar_TypeName(type)), p.count);
}
p.count = 0;
p.type = type;
p.type = -1;
p.hidden = true;
PathDirectory_Iterate2_Const(cvarDirectory, PCF_NO_BRANCH, NULL, PATHDIRECTORY_NOHASH, countVariable, &p);
Con_Printf("%12s: %u\n", Str_Text(CVar_TypeName(type)), p.count);
}
p.count = 0;
p.type = -1;
p.hidden = true;
PathDirectory_Iterate2_Const(cvarDirectory, PCF_NO_BRANCH, NULL, PATHDIRECTORY_NOHASH, countVariable, &p);
Con_Printf(" Total: %u\n Hidden: %u\n\n", PathDirectory_Size(cvarDirectory), p.count);
PathDirectory_DebugPrintHashDistribution(cvarDirectory);
PathDirectory_DebugPrint(cvarDirectory, CVARDIRECTORY_DELIMITER);
numCVars = PathDirectory_Size(cvarDirectory);
numCVarsHidden = p.count;
}
Con_Printf(" Total: %u\n Hidden: %u\n\n", numCVars, numCVarsHidden);

if(cvarDirectory)
{
PathDirectory_DebugPrintHashDistribution(cvarDirectory);
PathDirectory_DebugPrint(cvarDirectory, CVARDIRECTORY_DELIMITER);
}
return true;
}
#endif
Expand Down
26 changes: 19 additions & 7 deletions doomsday/engine/portable/src/fonts.c
Expand Up @@ -410,13 +410,16 @@ void Fonts_Shutdown(void)
{
fontnamespace_t* fn = &namespaces[i];

PathDirectory_Iterate(fn->directory, PCF_NO_BRANCH, NULL, PATHDIRECTORY_NOHASH, destroyRecord);
PathDirectory_Delete(fn->directory);
namespaces[i].directory = NULL;
if(fn->directory)
{
PathDirectory_Iterate(fn->directory, PCF_NO_BRANCH, NULL, PATHDIRECTORY_NOHASH, destroyRecord);
PathDirectory_Delete(fn->directory);
fn->directory = 0;
}

if(!fn->uniqueIdMap) continue;
free(fn->uniqueIdMap);
fn->uniqueIdMap = NULL;
free(fn->uniqueIdMap); fn->uniqueIdMap = 0;

fn->uniqueIdBase = 0;
fn->uniqueIdMapSize = 0;
fn->uniqueIdMapDirty = false;
Expand Down Expand Up @@ -542,8 +545,13 @@ void Fonts_ClearNamespace(fontnamespaceid_t namespaceId)
for(iter = from; iter <= to; ++iter)
{
fontnamespace_t* fn = &namespaces[iter - FONTNAMESPACE_FIRST];
PathDirectory_Iterate(fn->directory, PCF_NO_BRANCH, NULL, PATHDIRECTORY_NOHASH, destroyFontAndRecord);
PathDirectory_Clear(fn->directory);

if(fn->directory)
{
PathDirectory_Iterate(fn->directory, PCF_NO_BRANCH, NULL, PATHDIRECTORY_NOHASH, destroyFontAndRecord);
PathDirectory_Clear(fn->directory);
}

fn->uniqueIdMapDirty = true;
}
}
Expand Down Expand Up @@ -1223,6 +1231,8 @@ static int iterateDirectory(fontnamespaceid_t namespaceId,
for(iter = from; iter <= to; ++iter)
{
PathDirectory* directory = getDirectoryForNamespaceId(iter);
if(!directory) continue;

result = PathDirectory_Iterate2(directory, PCF_NO_BRANCH, NULL, PATHDIRECTORY_NOHASH, callback, parameters);
if(result) break;
}
Expand Down Expand Up @@ -1354,6 +1364,8 @@ static PathDirectoryNode** collectDirectoryNodes(fontnamespaceid_t namespaceId,
for(iterId = fromId; iterId <= toId; ++iterId)
{
PathDirectory* fontDirectory = getDirectoryForNamespaceId(iterId);
if(!fontDirectory) continue;

PathDirectory_Iterate2(fontDirectory, PCF_NO_BRANCH|PCF_MATCH_FULL, NULL,
PATHDIRECTORY_NOHASH, collectDirectoryNodeWorker, (void*)&p);
}
Expand Down
4 changes: 2 additions & 2 deletions doomsday/engine/portable/src/pathdirectory.cpp
Expand Up @@ -1097,8 +1097,6 @@ static int iteratePathsInHash(PathDirectory* pd,
ushort hash, PathDirectoryNodeType type, int flags, PathDirectoryNode* parent_,
int (*callback) (PathDirectoryNode* node, void* parameters), void* parameters)
{
if(!pd) return 0;

int result = 0;
SELF(pd);

Expand Down Expand Up @@ -1191,6 +1189,7 @@ static int iteratePathsInHash_Const(PathDirectory const* pd,
int PathDirectory_Iterate2(PathDirectory* pd, int flags, PathDirectoryNode* parent,
ushort hash, pathdirectory_iteratecallback_t callback, void* parameters)
{
DENG_ASSERT(pd);
int result = 0;
if(callback)
{
Expand All @@ -1214,6 +1213,7 @@ int PathDirectory_Iterate(PathDirectory* pd, int flags, PathDirectoryNode* paren
int PathDirectory_Iterate2_Const(PathDirectory const* pd, int flags, PathDirectoryNode const* parent,
ushort hash, pathdirectory_iterateconstcallback_t callback, void* parameters)
{
DENG_ASSERT(pd);
int result = 0;
if(callback)
{
Expand Down
2 changes: 2 additions & 0 deletions doomsday/engine/portable/src/wadfile.cpp
Expand Up @@ -287,6 +287,8 @@ struct WadFile::Instance
if(lumpNodeLut) return;

lumpNodeLut = new LumpNodeLut(self->lumpCount());
if(!lumpDirectory) return;

PathDirectory_Iterate2(reinterpret_cast<pathdirectory_s*>(lumpDirectory), PCF_NO_BRANCH,
NULL, PATHDIRECTORY_NOHASH, buildLumpNodeLutWorker, (void*)this);
}
Expand Down
2 changes: 2 additions & 0 deletions doomsday/engine/portable/src/zipfile.cpp
Expand Up @@ -422,6 +422,8 @@ struct ZipFile::Instance
if(lumpNodeLut) return;

lumpNodeLut = new LumpNodeLut(self->lumpCount());
if(!lumpDirectory) return;

PathDirectory_Iterate2(reinterpret_cast<pathdirectory_s*>(lumpDirectory), PCF_NO_BRANCH,
NULL, PATHDIRECTORY_NOHASH, buildLumpNodeLutWorker, (void*)this);
}
Expand Down

0 comments on commit ae2b0aa

Please sign in to comment.