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

Unified Diff: base/mac/scoped_nsexception_enabler.mm

Issue 8883040: [Mac] Ignore spell-checker exceptions. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: s/Calls/Executes/. Created 9 years 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « base/mac/scoped_nsexception_enabler.h ('k') | chrome/browser/spellchecker/spellchecker_mac.mm » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: base/mac/scoped_nsexception_enabler.mm
diff --git a/base/mac/scoped_nsexception_enabler.mm b/base/mac/scoped_nsexception_enabler.mm
index f5559f0455a26730b6f29b372345809ee258c5f0..52bddb2bb6e25143682acb35f3882db80a37eae7 100644
--- a/base/mac/scoped_nsexception_enabler.mm
+++ b/base/mac/scoped_nsexception_enabler.mm
@@ -12,6 +12,15 @@ using base::LazyInstance;
using base::LeakyLazyInstanceTraits;
using base::ThreadLocalBoolean;
+// When C++ exceptions are disabled, the C++ library defines |try| and
+// |catch| so as to allow exception-expecting C++ code to build properly when
+// language support for exceptions is not present. These macros interfere
+// with the use of |@try| and |@catch| in Objective-C files such as this one.
+// Undefine these macros here, after everything has been #included, since
+// there will be no C++ uses and only Objective-C uses from this point on.
+#undef try
+#undef catch
+
namespace {
// Whether to allow NSExceptions to be raised on the current thread.
@@ -31,6 +40,17 @@ void SetNSExceptionsAllowed(bool allowed) {
return g_exceptionsAllowed.Get().Set(allowed);
}
+id PerformSelectorIgnoringExceptions(NSObject* target, SEL sel) {
+ id ret = nil;
+ @try {
+ base::mac::ScopedNSExceptionEnabler enable;
+ ret = [target performSelector:sel];
+ }
+ @catch(id exception) {
+ }
+ return ret;
+}
+
ScopedNSExceptionEnabler::ScopedNSExceptionEnabler() {
was_enabled_ = GetNSExceptionsAllowed();
SetNSExceptionsAllowed(true);
« no previous file with comments | « base/mac/scoped_nsexception_enabler.h ('k') | chrome/browser/spellchecker/spellchecker_mac.mm » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698