Bug 1444086 - TlsScope should use WeakPtr. r=jrmuizel, a=RyanVM
authorJeff Gilbert <jgilbert@mozilla.com>
Tue, 27 Mar 2018 12:29:19 -0400
changeset 462906 17a3b84a2ac3689c682b7ec69d4ea49af9b39af2
parent 462905 16307dd2fdf1afc83ca85eb60fa22ad3ee05df16
child 462907 bfe7012b7d583b9f4fa3ff305bc569c0688cd1d3
push id1683
push usersfraser@mozilla.com
push dateThu, 26 Apr 2018 16:43:40 +0000
treeherdermozilla-release@5af6cb21869d [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersjrmuizel, RyanVM
bugs1444086
milestone60.0
Bug 1444086 - TlsScope should use WeakPtr. r=jrmuizel, a=RyanVM MozReview-Commit-ID: DX99PqmxMpF
gfx/gl/GLContext.h
--- a/gfx/gl/GLContext.h
+++ b/gfx/gl/GLContext.h
@@ -197,28 +197,30 @@ class GLContext
 public:
     MOZ_DECLARE_WEAKREFERENCE_TYPENAME(GLContext)
     static MOZ_THREAD_LOCAL(uintptr_t) sCurrentContext;
 
     bool mImplicitMakeCurrent;
     bool mUseTLSIsCurrent;
 
     class TlsScope final {
-        GLContext* const mGL;
+        const WeakPtr<GLContext> mGL;
         const bool mWasTlsOk;
     public:
         explicit TlsScope(GLContext* const gl)
             : mGL(gl)
             , mWasTlsOk(gl->mUseTLSIsCurrent)
         {
             mGL->mUseTLSIsCurrent = true;
         }
 
         ~TlsScope() {
-            mGL->mUseTLSIsCurrent = mWasTlsOk;
+            if (mGL) {
+                mGL->mUseTLSIsCurrent = mWasTlsOk;
+            }
         }
     };
 
 // -----------------------------------------------------------------------------
 // basic getters
 public:
 
     /**