Bug 1336510 - Part 2: Fix lambda captures of this in PresentationConnection, r=smaug
authorMichael Layzell <michael@thelayzells.com>
Fri, 03 Feb 2017 16:55:22 -0500
changeset 373838 57c46960a5f3bf1be5e34b27a8214b8f500288f2
parent 373837 ea1dda72c26d426d8b474af394455a3b44ac6837
child 373839 2b47a14041f5c66986083055d780c45bdf238cae
push id10863
push userjlorenzo@mozilla.com
push dateMon, 06 Mar 2017 23:02:23 +0000
treeherdermozilla-aurora@0931190cd725 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerssmaug
bugs1336510
milestone54.0a1
Bug 1336510 - Part 2: Fix lambda captures of this in PresentationConnection, r=smaug MozReview-Commit-ID: 2fuMHyspjhs
dom/presentation/PresentationConnection.cpp
--- a/dom/presentation/PresentationConnection.cpp
+++ b/dom/presentation/PresentationConnection.cpp
@@ -730,35 +730,36 @@ PresentationConnection::RemoveFromLoadGr
 void
 PresentationConnection::AsyncCloseConnectionWithErrorMsg(const nsAString& aMessage)
 {
   if (mState == PresentationConnectionState::Terminated) {
     return;
   }
 
   nsString message = nsString(aMessage);
+  RefPtr<PresentationConnection> self = this;
   nsCOMPtr<nsIRunnable> r =
-    NS_NewRunnableFunction([this, message]() -> void {
+    NS_NewRunnableFunction([self, message]() -> void {
       // Set |mState| to |PresentationConnectionState::Closed| here to avoid
       // calling |ProcessStateChanged|.
-      mState = PresentationConnectionState::Closed;
+      self->mState = PresentationConnectionState::Closed;
 
       // Make sure dispatching the event and closing the connection are invoked
       // at the same time by setting |aDispatchNow| to true.
       Unused << NS_WARN_IF(NS_FAILED(
-        DispatchConnectionCloseEvent(PresentationConnectionClosedReason::Error,
-                                      message,
-                                      true)));
+        self->DispatchConnectionCloseEvent(PresentationConnectionClosedReason::Error,
+                                           message,
+                                           true)));
 
       nsCOMPtr<nsIPresentationService> service =
         do_GetService(PRESENTATION_SERVICE_CONTRACTID);
       if(NS_WARN_IF(!service)) {
         return;
       }
 
       Unused << NS_WARN_IF(NS_FAILED(
-        service->CloseSession(mId,
-                              mRole,
+        service->CloseSession(self->mId,
+                              self->mRole,
                               nsIPresentationService::CLOSED_REASON_ERROR)));
     });
 
   Unused << NS_WARN_IF(NS_FAILED(NS_DispatchToMainThread(r)));
 }