Index: webrtc/base/asyncinvoker.cc |
diff --git a/webrtc/base/asyncinvoker.cc b/webrtc/base/asyncinvoker.cc |
index cabd8b506d0575ee3e3b41a479f6f7b9fcf63ee8..a143e25f19341bd2d3368c991aca8ab9c1e4d418 100644 |
--- a/webrtc/base/asyncinvoker.cc |
+++ b/webrtc/base/asyncinvoker.cc |
@@ -20,6 +20,7 @@ |
AsyncInvoker::~AsyncInvoker() { |
destroying_ = true; |
+ SignalInvokerDestroyed(); |
// Messages for this need to be cleared *before* our destructor is complete. |
MessageQueueManager::Clear(this); |
// And we need to wait for any invocations that are still in progress on |
@@ -125,9 +126,8 @@ |
calling_thread_(calling_thread) { |
calling_thread->SignalQueueDestroyed.connect( |
this, &NotifyingAsyncClosureBase::CancelCallback); |
- // Note: We don't need to listen for the invoker being destroyed, because it |
- // will wait for this closure to be destroyed (and pending_invocations_ to go |
- // to 0) before its destructor completes. |
+ invoker->SignalInvokerDestroyed.connect( |
+ this, &NotifyingAsyncClosureBase::CancelCallback); |
} |
NotifyingAsyncClosureBase::~NotifyingAsyncClosureBase() { |