Bug 1411977 - Part 4: Only try to dispatch the release of TransportLayers when there is a target thread. r?drno draft
authorByron Campen [:bwc] <docfaraday@gmail.com>
Thu, 25 Jan 2018 09:55:12 -0600
changeset 748502 5e85c43884ed35648af92b08128ff6078099b083
parent 748501 4780c1c84e8e99b7a882cd952d56eda48f31b5a1
child 748503 07bdde0c57c1effc5823aadbc68c39d90dd096ce
push id97190
push userbcampen@mozilla.com
push dateMon, 29 Jan 2018 22:41:18 +0000
reviewersdrno
bugs1411977
milestone60.0a1
Bug 1411977 - Part 4: Only try to dispatch the release of TransportLayers when there is a target thread. r?drno MozReview-Commit-ID: 8fOkZwcxKHy
media/mtransport/transportflow.cpp
--- 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()) {