summaryrefslogtreecommitdiffstats
path: root/o3d
diff options
context:
space:
mode:
authorkbr@google.com <kbr@google.com@0039d316-1c4b-4281-b951-d872f2087c98>2010-06-16 00:27:41 +0000
committerkbr@google.com <kbr@google.com@0039d316-1c4b-4281-b951-d872f2087c98>2010-06-16 00:27:41 +0000
commitdf13a7e7e3231bffa81a1e94c4e91d3c69bb3389 (patch)
tree4f1269654189e6850f21b62797c110514e520edb /o3d
parent97652631f65b357867d01ffe260d5b488002b190 (diff)
downloadchromium_src-df13a7e7e3231bffa81a1e94c4e91d3c69bb3389.zip
chromium_src-df13a7e7e3231bffa81a1e94c4e91d3c69bb3389.tar.gz
chromium_src-df13a7e7e3231bffa81a1e94c4e91d3c69bb3389.tar.bz2
Guard against the plugin being deleted unexpectedly.
BUG=none TEST=manually stress tested plugin creation and destruction Review URL: http://codereview.chromium.org/2848004 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@49869 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'o3d')
-rw-r--r--o3d/core/cross/client.cc10
-rw-r--r--o3d/plugin/cross/main.cc7
-rw-r--r--o3d/plugin/mac/main_mac.mm8
-rw-r--r--o3d/plugin/mac/o3d_layer.mm4
4 files changed, 27 insertions, 2 deletions
diff --git a/o3d/core/cross/client.cc b/o3d/core/cross/client.cc
index a6f9c32..271df8e42 100644
--- a/o3d/core/cross/client.cc
+++ b/o3d/core/cross/client.cc
@@ -252,6 +252,16 @@ void Client::RenderClientInner(bool present, bool send_callback) {
profiler_->ProfileStart("Render callback");
if (send_callback)
render_callback_manager_.Run(render_event_);
+
+ // Calling back to JavaScript may have caused the plugin to be
+ // torn down. Guard carefully against this.
+ if (!profiler_.IsAvailable()) {
+ if (renderer_.IsAvailable()) {
+ renderer_->FinishRendering();
+ }
+ return;
+ }
+
profiler_->ProfileStop("Render callback");
if (!render_tree_called_) {
diff --git a/o3d/plugin/cross/main.cc b/o3d/plugin/cross/main.cc
index fe49c7c..e552bce 100644
--- a/o3d/plugin/cross/main.cc
+++ b/o3d/plugin/cross/main.cc
@@ -109,8 +109,11 @@ void NPP_URLNotify(NPP instance, const char *url, NPReason reason,
void *notifyData) {
HANDLE_CRASHES;
PluginObject *obj = static_cast<PluginObject*>(instance->pdata);
- StreamManager *stream_manager = obj->stream_manager();
- stream_manager->URLNotify(url, reason, notifyData);
+ // Make sure the plugin hasn't been destroyed already.
+ if (obj) {
+ StreamManager *stream_manager = obj->stream_manager();
+ stream_manager->URLNotify(url, reason, notifyData);
+ }
}
NPError NPP_GetValue(NPP instance, NPPVariable variable, void *value) {
diff --git a/o3d/plugin/mac/main_mac.mm b/o3d/plugin/mac/main_mac.mm
index 6f3a15d..2daefe5 100644
--- a/o3d/plugin/mac/main_mac.mm
+++ b/o3d/plugin/mac/main_mac.mm
@@ -983,6 +983,14 @@ NPError NPP_Destroy(NPP instance, NPSavedData** save) {
// TODO(maf) / TODO(kbr): are we leaking AGL / CGL contexts?
+ if (obj->drawing_model_ == NPDrawingModelCoreAnimation) {
+ O3DLayer* layer = ObjO3DLayer(obj);
+ if (layer) {
+ // Prevent the layer from rendering any more.
+ [layer setPluginObject:NULL];
+ }
+ }
+
obj->TearDown();
NPN_ReleaseObject(obj);
instance->pdata = NULL;
diff --git a/o3d/plugin/mac/o3d_layer.mm b/o3d/plugin/mac/o3d_layer.mm
index a566f1b6..ee85df9 100644
--- a/o3d/plugin/mac/o3d_layer.mm
+++ b/o3d/plugin/mac/o3d_layer.mm
@@ -71,6 +71,10 @@ using o3d::DisplayWindowMac;
pixelFormat:(CGLPixelFormatObj)pf
forLayerTime:(CFTimeInterval)t
displayTime:(const CVTimeStamp *)ts {
+ // Watch out for the plugin being destroyed out from under us.
+ if (!obj_) {
+ return;
+ }
// Set the current context to the one given to us.
CGLSetCurrentContext(ctx);