Bug 1273227 - Fix an assertion in TextureClient::Unlock(). r=nical
MozReview-Commit-ID: JwWPe4F0NCq
--- 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)