diff --git a/src/DirManager.cpp b/src/DirManager.cpp index c39e4b83c..79f26c59e 100644 --- a/src/DirManager.cpp +++ b/src/DirManager.cpp @@ -934,15 +934,19 @@ BlockFile *DirManager::NewODDecodeBlockFile( return newBlockFile; } -bool DirManager::ContainsBlockFile(BlockFile *b) +bool DirManager::ContainsBlockFile(BlockFile *b) const { - return b ? mBlockFileHash[b->GetFileName().GetName()] == b : false; + if (!b) + return false; + BlockHash::const_iterator it = mBlockFileHash.find(b->GetFileName().GetName()); + return it != mBlockFileHash.end() && it->second == b; } -bool DirManager::ContainsBlockFile(wxString filepath) +bool DirManager::ContainsBlockFile(wxString filepath) const { // check what the hash returns in case the blockfile is from a different project - return mBlockFileHash[filepath] != NULL; + BlockHash::const_iterator it = mBlockFileHash.find(filepath); + return it != mBlockFileHash.end(); } // Adds one to the reference count of the block file, diff --git a/src/DirManager.h b/src/DirManager.h index cb8a64384..bcc10cac7 100644 --- a/src/DirManager.h +++ b/src/DirManager.h @@ -71,9 +71,9 @@ class DirManager: public XMLTagHandler { sampleCount aliasLen, int aliasChannel, int decodeType); /// Returns true if the blockfile pointed to by b is contained by the DirManager - bool ContainsBlockFile(BlockFile *b); + bool ContainsBlockFile(BlockFile *b) const; /// Check for existing using filename using complete filename - bool ContainsBlockFile(wxString filepath); + bool ContainsBlockFile(wxString filepath) const; // Adds one to the reference count of the block file, // UNLESS it is "locked", then it makes a new copy of