Bug 1273227 - Fix an assertion in TextureClient::Unlock(). r=nical
authorBotond Ballo <botond@mozilla.com>
Wed, 25 May 2016 13:16:25 -0400
changeset 372384 d667c7bfcc25d1f3ae4c7e29a5030d223f3eaf5a
parent 372383 5483a7f7649caeb0e86035ed2d10572164b3282a
child 372385 ddd9b902f9e11e0e18709accab05982245e27dbe
push id19519
push userbmo:rail@mozilla.com
push dateSat, 28 May 2016 13:01:27 +0000
reviewersnical
bugs1273227
milestone49.0a1
Bug 1273227 - Fix an assertion in TextureClient::Unlock(). r=nical MozReview-Commit-ID: JwWPe4F0NCq
gfx/layers/client/TextureClient.cpp
--- a/gfx/layers/client/TextureClient.cpp
+++ b/gfx/layers/client/TextureClient.cpp
@@ -1038,23 +1038,27 @@ TextureClient::RemoveFromCompositable(Co
 void
 TextureClient::SetRemoveFromCompositableWaiter(AsyncTransactionWaiter* aWaiter) {
   mRemoveFromCompositableWaiter = aWaiter;
 }
 
 already_AddRefed<gfx::DataSourceSurface>
 TextureClient::GetAsSurface()
 {
-  Lock(OpenMode::OPEN_READ);
+  if (!Lock(OpenMode::OPEN_READ)) {
+    return nullptr;
+  }
   RefPtr<gfx::DataSourceSurface> data;
-  RefPtr<gfx::DrawTarget> dt = BorrowDrawTarget();
-  if (dt) {
-    RefPtr<gfx::SourceSurface> surf = dt->Snapshot();
-    if (surf) {
-      data = surf->GetDataSurface();
+  {  // scope so that the DrawTarget is destroyed before Unlock()
+    RefPtr<gfx::DrawTarget> dt = BorrowDrawTarget();
+    if (dt) {
+      RefPtr<gfx::SourceSurface> surf = dt->Snapshot();
+      if (surf) {
+        data = surf->GetDataSurface();
+      }
     }
   }
   Unlock();
   return data.forget();
 }
 
 void
 TextureClient::PrintInfo(std::stringstream& aStream, const char* aPrefix)