| Index: webkit/glue/plugins/webplugin_delegate_impl_mac.mm
|
| diff --git a/webkit/glue/plugins/webplugin_delegate_impl_mac.mm b/webkit/glue/plugins/webplugin_delegate_impl_mac.mm
|
| index 58e3b3db299a8ae45009844aa66dcc18a2e32ca4..b22808898151193cb5ec6cf8b4cc3e0c743c87de 100644
|
| --- a/webkit/glue/plugins/webplugin_delegate_impl_mac.mm
|
| +++ b/webkit/glue/plugins/webplugin_delegate_impl_mac.mm
|
| @@ -567,7 +567,7 @@ void WebPluginDelegateImpl::SetContainerVisibility(bool is_visible) {
|
| // change anything.
|
| if (!clip_rect_.IsEmpty()) {
|
| #ifndef NP_NO_CARBON
|
| - if (instance()->event_model() == NPEventModelCarbon)
|
| + if (instance() && instance()->event_model() == NPEventModelCarbon)
|
| UpdateIdleEventRate();
|
| #endif
|
| WindowlessSetWindow(true);
|
| @@ -949,8 +949,12 @@ bool WebPluginDelegateImpl::PlatformHandleInputEvent(
|
| // notification that we are taking the keyboard focus. We can't just key
|
| // off of incoming calls to SetFocus, since WebKit may already think we
|
| // have it if we were the most recently focused element on our parent tab.
|
| - if (event.type == WebInputEvent::MouseDown && !have_focus_)
|
| + if (event.type == WebInputEvent::MouseDown && !have_focus_) {
|
| SetFocus();
|
| + // Make sure that the plugin is still there after handling the focus event.
|
| + if (!instance())
|
| + return false;
|
| + }
|
|
|
| #ifndef NP_NO_CARBON
|
| if (instance()->event_model() == NPEventModelCarbon) {
|
| @@ -1017,7 +1021,7 @@ bool WebPluginDelegateImpl::PlatformHandleInputEvent(
|
| }
|
|
|
| #ifndef NP_NO_CARBON
|
| - if (instance()->event_model() == NPEventModelCarbon &&
|
| + if (instance() && instance()->event_model() == NPEventModelCarbon &&
|
| instance()->drawing_model() == NPDrawingModelCoreGraphics &&
|
| cg_context_.context == old_context_weak)
|
| CGContextRestoreGState(cg_context_.context);
|
| @@ -1029,7 +1033,7 @@ bool WebPluginDelegateImpl::PlatformHandleInputEvent(
|
| #ifndef NP_NO_CARBON
|
| void WebPluginDelegateImpl::FireIdleEvent() {
|
| // Avoid a race condition between IO and UI threads during plugin shutdown
|
| - if (!instance_)
|
| + if (!instance())
|
| return;
|
|
|
| ScopedActiveDelegate active_delegate(this);
|
| @@ -1047,6 +1051,9 @@ void WebPluginDelegateImpl::FireIdleEvent() {
|
| reinterpret_cast<void *>(event.message) != cg_context_.window)
|
| continue;
|
| instance()->NPP_HandleEvent(&event);
|
| + // If the plugin went away during event handling, we're done.
|
| + if (!instance())
|
| + return;
|
| }
|
| break;
|
| }
|
| @@ -1072,7 +1079,7 @@ void WebPluginDelegateImpl::FireIdleEvent() {
|
| // repaint.
|
| // TODO: only do this if the contents of the offscreen window has changed,
|
| // so as not to spam the renderer with an unchanging image.
|
| - if (instance()->drawing_model() == NPDrawingModelQuickDraw)
|
| + if (instance() && instance()->drawing_model() == NPDrawingModelQuickDraw)
|
| instance()->webplugin()->Invalidate();
|
| #endif
|
| }
|
|
|