diff options
author | avi@chromium.org <avi@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-08-05 14:35:34 +0000 |
---|---|---|
committer | avi@chromium.org <avi@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-08-05 14:35:34 +0000 |
commit | d600731674dc3d2171fa4cb5efe86e498d86157d (patch) | |
tree | 633f12a37899d5f0e9efb76e37305e468632cc3e /ui/gfx/scoped_ns_graphics_context_save_gstate_mac.mm | |
parent | 7d304a9d8904d47742e9ec4a2b379e65b0c0391f (diff) | |
download | chromium_src-d600731674dc3d2171fa4cb5efe86e498d86157d.zip chromium_src-d600731674dc3d2171fa4cb5efe86e498d86157d.tar.gz chromium_src-d600731674dc3d2171fa4cb5efe86e498d86157d.tar.bz2 |
Always call the class methods to save/restore contexts.
If the current context was ever nil, sending a "restore" message would be a no-op and would likely leave an out-of-scope context as current.
BUG=90140
TEST=repeatedly select items in an open file dialog in column mode; no crash
Review URL: http://codereview.chromium.org/7572031
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@95611 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'ui/gfx/scoped_ns_graphics_context_save_gstate_mac.mm')
-rw-r--r-- | ui/gfx/scoped_ns_graphics_context_save_gstate_mac.mm | 15 |
1 files changed, 8 insertions, 7 deletions
diff --git a/ui/gfx/scoped_ns_graphics_context_save_gstate_mac.mm b/ui/gfx/scoped_ns_graphics_context_save_gstate_mac.mm index f3992ea..6b19d8c 100644 --- a/ui/gfx/scoped_ns_graphics_context_save_gstate_mac.mm +++ b/ui/gfx/scoped_ns_graphics_context_save_gstate_mac.mm @@ -4,19 +4,20 @@ #include "ui/gfx/scoped_ns_graphics_context_save_gstate_mac.h" -#include <AppKit/AppKit.h> +#import <AppKit/AppKit.h> + +#include "base/logging.h" namespace gfx { -ScopedNSGraphicsContextSaveGState::ScopedNSGraphicsContextSaveGState( - NSGraphicsContext* context) : context_([context retain]) { - if (!context_) - context_.reset([[NSGraphicsContext currentContext] retain]); - [context_ saveGraphicsState]; +ScopedNSGraphicsContextSaveGState::ScopedNSGraphicsContextSaveGState() + : context_([NSGraphicsContext currentContext]) { + [NSGraphicsContext saveGraphicsState]; } ScopedNSGraphicsContextSaveGState::~ScopedNSGraphicsContextSaveGState() { - [context_ restoreGraphicsState]; + [NSGraphicsContext restoreGraphicsState]; + DCHECK_EQ(context_, [NSGraphicsContext currentContext]); } } // namespace gfx |