diff options
author | Jay Freeman (saurik) <saurik@saurik.com> | 2011-02-17 02:21:12 -0800 |
---|---|---|
committer | Jay Freeman (saurik) <saurik@saurik.com> | 2011-02-17 02:21:53 -0800 |
commit | 0893a034f90f80629c5b634b564bdd4977c48369 (patch) | |
tree | e68bb0e82069a2b495d100ccd337f062db72fb6d /UICaboodle | |
parent | 72bdb25841675b854c4f782dd0a3f6decd928a3f (diff) |
Use C++ RAII for WebThreadLock/Unlock().
Diffstat (limited to 'UICaboodle')
-rw-r--r-- | UICaboodle/BrowserView.mm | 22 |
1 files changed, 15 insertions, 7 deletions
diff --git a/UICaboodle/BrowserView.mm b/UICaboodle/BrowserView.mm index 8bc0eff..956e359 100644 --- a/UICaboodle/BrowserView.mm +++ b/UICaboodle/BrowserView.mm @@ -35,6 +35,18 @@ extern NSString * const kCAFilterNearest; #define lprintf(args...) fprintf(stderr, args) +// WebThreadLocked {{{ +struct WebThreadLocked { + _finline WebThreadLocked() { + WebThreadLock(); + } + + _finline ~WebThreadLocked() { + WebThreadUnlock(); + } +}; +// }}} + template <typename Type_> static inline void CYRelease(Type_ &value) { if (value != nil) { @@ -525,9 +537,8 @@ static void $UIWebViewWebViewDelegate$webViewClose$(UIWebViewWebViewDelegate *se error_ = false; - WebThreadLock(); + WebThreadLocked lock; [webview_ loadRequest:request]; - WebThreadUnlock(); } - (void) reloadURL { @@ -892,9 +903,8 @@ static void $UIWebViewWebViewDelegate$webViewClose$(UIWebViewWebViewDelegate *se if (button == [alert cancelButtonIndex]) { } else if (button == [alert firstOtherButtonIndex]) { if (request_ != nil) { - WebThreadLock(); + WebThreadLocked lock; [webview_ loadRequest:request_]; - WebThreadUnlock(); } } @@ -1108,7 +1118,7 @@ static void $UIWebViewWebViewDelegate$webViewClose$(UIWebViewWebViewDelegate *se } - (void) callFunction:(WebScriptObject *)function { - WebThreadLock(); + WebThreadLocked lock; WebView *webview([[webview_ _documentView] webView]); WebFrame *frame([webview mainFrame]); @@ -1141,8 +1151,6 @@ static void $UIWebViewWebViewDelegate$webViewClose$(UIWebViewWebViewDelegate *se settings->setJavaScriptCanOpenWindowsAutomatically(no);*/ [preferences setJavaScriptCanOpenWindowsAutomatically:maybe]; - - WebThreadUnlock(); } - (void) reloadButtonClicked { |