Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(361)

Side by Side Diff: chrome/browser/icon_loader_win.cc

Issue 7753009: In icon_loader_win.cc, if CreateSkBitmapFromHICON fails, don't pass NULL to gfx::Image and crash. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 9 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "chrome/browser/icon_loader.h" 5 #include "chrome/browser/icon_loader.h"
6 6
7 #include <windows.h> 7 #include <windows.h>
8 #include <shellapi.h> 8 #include <shellapi.h>
9 9
10 #include "base/message_loop.h" 10 #include "base/message_loop.h"
(...skipping 24 matching lines...) Expand all
35 35
36 ICONINFO icon_info = { 0 }; 36 ICONINFO icon_info = { 0 };
37 BITMAP bitmap_info = { 0 }; 37 BITMAP bitmap_info = { 0 };
38 38
39 BOOL r = ::GetIconInfo(file_info.hIcon, &icon_info); 39 BOOL r = ::GetIconInfo(file_info.hIcon, &icon_info);
40 DCHECK(r); 40 DCHECK(r);
41 r = ::GetObject(icon_info.hbmMask, sizeof(bitmap_info), &bitmap_info); 41 r = ::GetObject(icon_info.hbmMask, sizeof(bitmap_info), &bitmap_info);
42 DCHECK(r); 42 DCHECK(r);
43 43
44 gfx::Size icon_size(bitmap_info.bmWidth, bitmap_info.bmHeight); 44 gfx::Size icon_size(bitmap_info.bmWidth, bitmap_info.bmHeight);
45 image_.reset(new gfx::Image(
46 IconUtil::CreateSkBitmapFromHICON(file_info.hIcon, icon_size)));
47 45
46 const SkBitmap* bitmap =
47 IconUtil::CreateSkBitmapFromHICON(file_info.hIcon, icon_size);
48 if (!bitmap) {
49 LOG(ERROR) << "Decoding HICON for group " << group_ << " failed";
50 // Don't create a gfx::Image and crash. The delegate won't be notified.
Peter Kasting 2011/08/26 18:12:56 Should we instead set |image_| to a non-NULL but z
Robert Sesek 2011/08/26 19:38:28 No, we should actually notify with a NULL pointer,
51 return;
52 }
53
54 image_.reset(new gfx::Image(bitmap));
48 target_message_loop_->PostTask(FROM_HERE, 55 target_message_loop_->PostTask(FROM_HERE,
49 NewRunnableMethod(this, &IconLoader::NotifyDelegate)); 56 NewRunnableMethod(this, &IconLoader::NotifyDelegate));
50 } 57 }
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698