Bug 1336510 - Part 2: Fix lambda captures of this in PresentationConnection, r=smaug
☠☠ backed out by b1d2452c7c17 ☠ ☠
authorMichael Layzell <michael@thelayzells.com>
Fri, 03 Feb 2017 16:55:22 -0500
changeset 343190 71be73be6c4ed0964264c1f437d68f8a3f706128
parent 343189 02ccacdbbb93b26120032ad128273ce68705a3cd
child 343191 2075037694eda246a9bda0bc545898702c18f1dc
push id31372
push usercbook@mozilla.com
push dateThu, 16 Feb 2017 12:16:10 +0000
treeherdermozilla-central@2737f66ad6ac [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerssmaug
bugs1336510
milestone54.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 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
@@ -728,35 +728,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)));
 }