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

Unified Diff: base/message_pump_mac.mm

Issue 149082: Handle message pump sources firing without delegates available (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Created 11 years, 6 months 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 | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: base/message_pump_mac.mm
===================================================================
--- base/message_pump_mac.mm (revision 19366)
+++ base/message_pump_mac.mm (working copy)
@@ -181,6 +181,12 @@
// 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 @@
// 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 @@
// 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 @@
// 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()) {
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698