Bug 778057: Fix this type of crash bug forever. r=dRdR

This commit is contained in:
Chris Jones 2012-07-27 00:15:49 -07:00
parent f3a432b0ee
commit b1de3b0be9

View File

@ -68,6 +68,17 @@ static pthread_t sFramebufferWatchThread;
namespace {
android::FramebufferNativeWindow*
NativeWindow()
{
if (!gNativeWindow) {
// We (apparently) don't have a way to tell if allocating the
// fbs succeeded or failed.
gNativeWindow = new android::FramebufferNativeWindow();
}
return gNativeWindow;
}
static PRUint32
EffectiveScreenRotation()
{
@ -150,10 +161,6 @@ nsWindow::nsWindow()
NS_RUNTIMEABORT("Failed to create framebufferWatcherThread, aborting...");
}
// We (apparently) don't have a way to tell if allocating the
// fbs succeeded or failed.
gNativeWindow = new android::FramebufferNativeWindow();
nsIntSize screenSize;
bool gotFB = Framebuffer::GetSize(&screenSize);
MOZ_ASSERT(gotFB);
@ -455,7 +462,7 @@ nsWindow::GetNativeData(PRUint32 aDataType)
{
switch (aDataType) {
case NS_NATIVE_WINDOW:
return gNativeWindow;
return NativeWindow();
case NS_NATIVE_WIDGET:
return this;
}
@ -491,7 +498,7 @@ nsWindow::ReparentNativeWidget(nsIWidget* aNewParent)
float
nsWindow::GetDPI()
{
return gNativeWindow->xdpi;
return NativeWindow()->xdpi;
}
LayerManager *
@ -648,7 +655,7 @@ nsScreenGonk::GetAvailRect(PRInt32 *outLeft, PRInt32 *outTop,
static uint32_t
ColorDepth()
{
switch (gNativeWindow->getDevice()->format) {
switch (NativeWindow()->getDevice()->format) {
case GGL_PIXEL_FORMAT_RGB_565:
return 16;
case GGL_PIXEL_FORMAT_RGBA_8888: