| 243 | } |
| 244 | |
| 245 | bool AvatarCache::TrimBitmap() |
| 246 | { |
| 247 | int maxAge = 0; |
| 248 | std::string rid = ""; |
| 249 | |
| 250 | for (auto &b : m_profileToBitmap) { |
| 251 | if (maxAge < b.second.m_age && |
| 252 | b.second.m_image != GetDefaultImage() && |
| 253 | b.second.m_image != HIMAGE_ERROR && |
| 254 | b.second.m_image != HIMAGE_LOADING) { |
| 255 | maxAge = b.second.m_age; |
| 256 | rid = b.first; |
| 257 | } |
| 258 | } |
| 259 | |
| 260 | if (rid.empty()) return false; |
| 261 | |
| 262 | auto iter = m_profileToBitmap.find(rid); |
| 263 | assert(iter != m_profileToBitmap.end()); |
| 264 | |
| 265 | auto iter2 = m_loadingResources.find(m_imagePlaces[iter->first].GetURL()); |
| 266 | |
| 267 | if (iter2 != m_loadingResources.end()) |
| 268 | m_loadingResources.erase(iter2); |
| 269 | |
| 270 | DbgPrintW("Deleting bitmap %s", rid.c_str()); |
| 271 | DeleteImageIfNeeded(iter->second.m_image); |
| 272 | m_profileToBitmap.erase(iter); |
| 273 | |
| 274 | return true; |
| 275 | } |
| 276 | |
| 277 | int AvatarCache::TrimBitmaps(int count) |
| 278 | { |