From 7c17ce507559257c39b895a5d04302e6dc0f3fb1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fabrice=20Desr=C3=A9?= Date: Thu, 11 Feb 2016 14:05:11 -0800 Subject: [PATCH] Bug 1247570 - unbreak widget/gonk/nativewindow/FakeSurfaceComposer.cpp r=gwagner --- widget/gonk/nativewindow/FakeSurfaceComposer.cpp | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/widget/gonk/nativewindow/FakeSurfaceComposer.cpp b/widget/gonk/nativewindow/FakeSurfaceComposer.cpp index d6a0c4b1757..f6cdf297654 100644 --- a/widget/gonk/nativewindow/FakeSurfaceComposer.cpp +++ b/widget/gonk/nativewindow/FakeSurfaceComposer.cpp @@ -482,17 +482,18 @@ FakeSurfaceComposer::captureScreenImp(const sp& producer reqWidth = (!reqWidth) ? hw_w : reqWidth; reqHeight = (!reqHeight) ? hw_h : reqHeight; - nsScreenGonk* screenPtr = screen.forget().take(); nsCOMPtr runnable = - NS_NewRunnableFunction([screenPtr, reqWidth, reqHeight, producer, wrapper]() { + NS_NewRunnableFunction([screen, reqWidth, reqHeight, producer, wrapper]() { // create a surface (because we're a producer, and we need to // dequeue/queue a buffer) sp sur = new Surface(producer); ANativeWindow* window = sur.get(); + // The closure makes screen const and we can't call forget() on it. + RefPtr screenAlias = screen; if (native_window_api_connect(window, NATIVE_WINDOW_API_EGL) != NO_ERROR) { static_cast(producer->asBinder().get())->exit(BAD_VALUE); - NS_ReleaseOnMainThread(screenPtr); + NS_ReleaseOnMainThread(screenAlias.forget()); return; } uint32_t usage = GRALLOC_USAGE_SW_READ_OFTEN | GRALLOC_USAGE_SW_WRITE_OFTEN | @@ -509,7 +510,7 @@ FakeSurfaceComposer::captureScreenImp(const sp& producer ANativeWindowBuffer* buffer; result = native_window_dequeue_buffer_and_wait(window, &buffer); if (result == NO_ERROR) { - nsresult rv = screenPtr->MakeSnapshot(buffer); + nsresult rv = screen->MakeSnapshot(buffer); if (rv != NS_OK) { result = INVALID_OPERATION; } @@ -520,7 +521,7 @@ FakeSurfaceComposer::captureScreenImp(const sp& producer } native_window_api_disconnect(window, NATIVE_WINDOW_API_EGL); static_cast(producer->asBinder().get())->exit(result); - NS_ReleaseOnMainThread(screenPtr); + NS_ReleaseOnMainThread(screenAlias.forget()); }); mozilla::layers::CompositorParent::CompositorLoop()->PostTask(