Fix #1576 (crash when viewing other online user's friends).
This commit is contained in:
parent
388937a487
commit
6cdce11fb7
@ -122,17 +122,19 @@ void ProfileManager::addToCache(OnlineProfile * profile)
|
|||||||
void ProfileManager::addDirectToCache(OnlineProfile* profile)
|
void ProfileManager::addDirectToCache(OnlineProfile* profile)
|
||||||
{
|
{
|
||||||
assert(profile != NULL);
|
assert(profile != NULL);
|
||||||
if (m_profiles_cache.size() == m_max_cache_size)
|
if (m_profiles_cache.size() >= m_max_cache_size)
|
||||||
{
|
{
|
||||||
// We have to replace a cached entry, find one entry that
|
// Cache already full, try to find entries that
|
||||||
// doesn't have its used bit set
|
// don't have their used bit set
|
||||||
ProfilesMap::iterator iter;
|
ProfilesMap::iterator iter;
|
||||||
for (iter = m_profiles_cache.begin(); iter != m_profiles_cache.end();)
|
for (iter = m_profiles_cache.begin(); iter != m_profiles_cache.end();)
|
||||||
{
|
{
|
||||||
if (!iter->second->getCacheBit())
|
if (!iter->second->getCacheBit())
|
||||||
{
|
{
|
||||||
delete iter->second;
|
delete iter->second;
|
||||||
m_profiles_cache.erase(iter);
|
iter = m_profiles_cache.erase(iter);
|
||||||
|
// Keep on deleting till enough space is available.
|
||||||
|
if(m_profiles_cache.size()<m_max_cache_size)
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@ -143,7 +145,6 @@ void ProfileManager::addDirectToCache(OnlineProfile* profile)
|
|||||||
}
|
}
|
||||||
|
|
||||||
m_profiles_cache[profile->getID()] = profile;
|
m_profiles_cache[profile->getID()] = profile;
|
||||||
assert(m_profiles_cache.size() <= m_max_cache_size);
|
|
||||||
} // addDirectToCache
|
} // addDirectToCache
|
||||||
|
|
||||||
// ------------------------------------------------------------------------
|
// ------------------------------------------------------------------------
|
||||||
@ -175,7 +176,7 @@ bool ProfileManager::isInCache(const uint32_t id)
|
|||||||
void ProfileManager::updateCacheBits(OnlineProfile * profile)
|
void ProfileManager::updateCacheBits(OnlineProfile * profile)
|
||||||
{
|
{
|
||||||
profile->setCacheBit(true);
|
profile->setCacheBit(true);
|
||||||
if (m_profiles_cache.size() == m_max_cache_size)
|
if (m_profiles_cache.size() >= m_max_cache_size)
|
||||||
{
|
{
|
||||||
ProfilesMap::iterator iter;
|
ProfilesMap::iterator iter;
|
||||||
for (iter = m_profiles_cache.begin();
|
for (iter = m_profiles_cache.begin();
|
||||||
|
Loading…
x
Reference in New Issue
Block a user