| Index: ui/base/resource/resource_bundle_mac.mm
|
| diff --git a/ui/base/resource/resource_bundle_mac.mm b/ui/base/resource/resource_bundle_mac.mm
|
| index 1a238a72c08d230a14f6863ce180027f2fd76086..3e04df9cd5b5a9f1022f7a5c2cfcb8768ddc2838 100644
|
| --- a/ui/base/resource/resource_bundle_mac.mm
|
| +++ b/ui/base/resource/resource_bundle_mac.mm
|
| @@ -62,19 +62,9 @@ FilePath ResourceBundle::GetLocaleFilePath(const std::string& app_locale) {
|
|
|
| gfx::Image& ResourceBundle::GetNativeImageNamed(int resource_id) {
|
| // Check to see if the image is already in the cache.
|
| - {
|
| - base::AutoLock lock(*lock_);
|
| - ImageMap::const_iterator found = images_.find(resource_id);
|
| - if (found != images_.end()) {
|
| - if (!found->second->HasRepresentation(gfx::Image::kNSImageRep)) {
|
| - DLOG(WARNING) << "ResourceBundle::GetNativeImageNamed() is returning a"
|
| - << " cached gfx::Image that isn't backed by an NSImage. The image"
|
| - << " will be converted, rather than going through the NSImage loader."
|
| - << " resource_id = " << resource_id;
|
| - }
|
| - return *found->second;
|
| - }
|
| - }
|
| + std::vector<gfx::Image*> images;
|
| + if (GetImagesFromCacheNamed(resource_id, images) && !images.empty())
|
| + return **images.begin();
|
|
|
| // Load the raw data from the resource pack.
|
| scoped_refptr<RefCountedStaticMemory> data(
|
| @@ -89,16 +79,21 @@ gfx::Image& ResourceBundle::GetNativeImageNamed(int resource_id) {
|
|
|
| // Cache the converted image.
|
| if (ns_image.get()) {
|
| - base::AutoLock lock(*lock_);
|
| -
|
| - // Another thread raced the load and has already cached the image.
|
| - if (images_.count(resource_id)) {
|
| - return *images_[resource_id];
|
| + {
|
| + base::AutoLock lock(*lock_);
|
| +
|
| + // Has another thread raced the load and has already cached the image?
|
| + if (!images_.count(resource_id)) {
|
| + gfx::Image* image = new gfx::Image(ns_image.release());
|
| + std::vector<gfx::Image*>* images_ptr = new std::vector<gfx::Image*>;
|
| + images_ptr->push_back(image);
|
| + images_[resource_id] = images_ptr;
|
| + return *image;
|
| + }
|
| }
|
|
|
| - gfx::Image* image = new gfx::Image(ns_image.release());
|
| - images_[resource_id] = image;
|
| - return *image;
|
| + if (GetImagesFromCacheNamed(resource_id, images) && !images.empty())
|
| + return **images.begin();
|
| }
|
|
|
| LOG(WARNING) << "Unable to load image with id " << resource_id;
|
|
|