Bug 1411977 - Part 4: Only try to dispatch the release of TransportLayers when there is a target thread. r?drno
MozReview-Commit-ID: 8fOkZwcxKHy
--- a/media/mtransport/transportflow.cpp
+++ b/media/mtransport/transportflow.cpp
@@ -30,20 +30,22 @@ TransportFlow::~TransportFlow() {
// Push the destruction onto the STS thread. Note that there
// is still some possibility that someone is accessing this
// object simultaneously, but as long as smart pointer discipline
// is maintained, it shouldn't be possible to access and
// destroy it simultaneously. The conversion to an nsAutoPtr
// ensures automatic destruction of the queue at exit of
// DestroyFinal.
- nsAutoPtr<std::deque<TransportLayer*>> layers_tmp(layers_.release());
- RUN_ON_THREAD(target_,
- WrapRunnableNM(&TransportFlow::DestroyFinal, layers_tmp),
- NS_DISPATCH_NORMAL);
+ if (target_) {
+ nsAutoPtr<std::deque<TransportLayer*>> layers_tmp(layers_.release());
+ RUN_ON_THREAD(target_,
+ WrapRunnableNM(&TransportFlow::DestroyFinal, layers_tmp),
+ NS_DISPATCH_NORMAL);
+ }
}
void TransportFlow::DestroyFinal(nsAutoPtr<std::deque<TransportLayer *> > layers) {
ClearLayers(layers.get());
}
void TransportFlow::ClearLayers(std::queue<TransportLayer *>* layers) {
while (!layers->empty()) {