Bug 1273227 - Fix an assertion in TextureClient::Unlock(). r=nical draft
authorBotond Ballo <botond@mozilla.com>
Wed, 25 May 2016 13:16:25 -0400
changeset 371039 82262bd0a1ca7a0aa32e7007578b5b00e8139f0f
parent 370842 d6d4e8417d2fd71fdf47c319b7a217f6ace9d5a5
child 371130 62a2f6e79150e4acff4a833d7c128167f1c41941
push id19215
push userbballo@mozilla.com
push dateWed, 25 May 2016 21:08:36 +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)