Bug 1419363 - Switch to WeakPtr. r=jib
authorAndreas Pehrson <pehrsons@mozilla.com>
Fri, 01 Dec 2017 10:52:18 -0500
changeset 394571 e0a21cc26e07
parent 394570 1f6112300d6e
child 394572 958496eddbcc
push id97912
push userryanvm@gmail.com
push dateFri, 01 Dec 2017 15:55:03 +0000
treeherdermozilla-inbound@e0a21cc26e07 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersjib
bugs1419363
milestone59.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1419363 - Switch to WeakPtr. r=jib
dom/html/HTMLMediaElement.cpp
--- a/dom/html/HTMLMediaElement.cpp
+++ b/dom/html/HTMLMediaElement.cpp
@@ -5232,21 +5232,24 @@ class HTMLMediaElement::MediaStreamTrack
 public:
   explicit MediaStreamTracksAvailableCallback(HTMLMediaElement* aElement):
       OnTracksAvailableCallback(), mElement(aElement)
     {}
   virtual void NotifyTracksAvailable(DOMMediaStream* aStream)
   {
     NS_ASSERTION(NS_IsMainThread(), "Should be on main thread.");
 
+    if (!mElement) {
+      return;
+    }
     mElement->NotifyMediaStreamTracksAvailable(aStream);
   }
 
 private:
-  HTMLMediaElement* mElement;
+  WeakPtr<HTMLMediaElement> mElement;
 };
 
 class HTMLMediaElement::MediaStreamTrackListener :
   public DOMMediaStream::TrackListener
 {
 public:
   explicit MediaStreamTrackListener(HTMLMediaElement* aElement):
       mElement(aElement) {}