summaryrefslogtreecommitdiffstats
path: root/base
diff options
context:
space:
mode:
authormark@chromium.org <mark@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-06-26 17:58:40 +0000
committermark@chromium.org <mark@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-06-26 17:58:40 +0000
commitd0fe06123dc0d08b75e75d2ca3b67cb0b8d40517 (patch)
treebaced627873cbecec33cabb48d27978413f2efdd /base
parent4a63ae1381005ba988ca6f49a6c9256ab634db12 (diff)
downloadchromium_src-d0fe06123dc0d08b75e75d2ca3b67cb0b8d40517.zip
chromium_src-d0fe06123dc0d08b75e75d2ca3b67cb0b8d40517.tar.gz
chromium_src-d0fe06123dc0d08b75e75d2ca3b67cb0b8d40517.tar.bz2
Gracefully do nothing when run loop sources fire and no delegate is available.
This can happen if foreign code spins the run loop without Run being on the stack. BUG=2708 TEST=none Review URL: http://codereview.chromium.org/149082 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@19382 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'base')
-rw-r--r--base/message_pump_mac.mm26
1 files changed, 26 insertions, 0 deletions
diff --git a/base/message_pump_mac.mm b/base/message_pump_mac.mm
index 007d202..ccd45f5 100644
--- a/base/message_pump_mac.mm
+++ b/base/message_pump_mac.mm
@@ -181,6 +181,12 @@ void MessagePumpCFRunLoopBase::RunWorkSource(void* info) {
// Called by MessagePumpCFRunLoopBase::RunWorkSource.
bool MessagePumpCFRunLoopBase::RunWork() {
+ if (!delegate_) {
+ // This point can be reached with a NULL delegate_ if Run is not on the
+ // stack but foreign code is spinning the CFRunLoop.
+ return false;
+ }
+
// If we're on the main event loop, the NSApp runloop won't clean up the
// autorelease pool until there is a UI event, so use a local one for any
// autoreleased objects to ensure they go away sooner.
@@ -205,6 +211,12 @@ void MessagePumpCFRunLoopBase::RunDelayedWorkSource(void* info) {
// Called by MessagePumpCFRunLoopBase::RunDelayedWorkSource.
bool MessagePumpCFRunLoopBase::RunDelayedWork() {
+ if (!delegate_) {
+ // This point can be reached with a NULL delegate_ if Run is not on the
+ // stack but foreign code is spinning the CFRunLoop.
+ return false;
+ }
+
// If we're on the main event loop, the NSApp runloop won't clean up the
// autorelease pool until there is a UI event, so use a local one for any
// autoreleased objects to ensure they go away sooner.
@@ -239,6 +251,12 @@ void MessagePumpCFRunLoopBase::RunIdleWorkSource(void* info) {
// Called by MessagePumpCFRunLoopBase::RunIdleWorkSource.
bool MessagePumpCFRunLoopBase::RunIdleWork() {
+ if (!delegate_) {
+ // This point can be reached with a NULL delegate_ if Run is not on the
+ // stack but foreign code is spinning the CFRunLoop.
+ return false;
+ }
+
// If we're on the main event loop, the NSApp runloop won't clean up the
// autorelease pool until there is a UI event, so use a local one for any
// autoreleased objects to ensure they go away sooner.
@@ -263,6 +281,14 @@ void MessagePumpCFRunLoopBase::RunNestingDeferredWorkSource(void* info) {
// Called by MessagePumpCFRunLoopBase::RunNestingDeferredWorkSource.
bool MessagePumpCFRunLoopBase::RunNestingDeferredWork() {
+ if (!delegate_) {
+ // This point can be reached with a NULL delegate_ if Run is not on the
+ // stack but foreign code is spinning the CFRunLoop. There's no sense in
+ // attempting to do any work or signalling the work sources because
+ // without a delegate, work is not possible.
+ return false;
+ }
+
// Immediately try work in priority order.
if (!RunWork()) {
if (!RunDelayedWork()) {