From fb44a1713684da1b9f922b3e3939d9a246128a66 Mon Sep 17 00:00:00 2001 From: "kmcclusk%netscape.com" Date: Mon, 8 Oct 2001 20:17:26 +0000 Subject: [PATCH] Pass back an error when allocating offscreen fails on GTK. bug=70424 r=pavlov@netscape.com, sr=attinasi@netscape.com --- gfx/src/gtk/nsDrawingSurfaceGTK.cpp | 2 ++ gfx/src/gtk/nsRenderingContextGTK.cpp | 9 ++++++--- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/gfx/src/gtk/nsDrawingSurfaceGTK.cpp b/gfx/src/gtk/nsDrawingSurfaceGTK.cpp index dd9d0a95078e..c6de35db74d2 100644 --- a/gfx/src/gtk/nsDrawingSurfaceGTK.cpp +++ b/gfx/src/gtk/nsDrawingSurfaceGTK.cpp @@ -265,6 +265,8 @@ NS_IMETHODIMP nsDrawingSurfaceGTK :: Init(GdkDrawable *aDrawable, GdkGC *aGC) gdk_image_destroy(mImage); mImage = nsnull; + g_return_val_if_fail(mPixmap != nsnull, NS_ERROR_FAILURE); + return NS_OK; } diff --git a/gfx/src/gtk/nsRenderingContextGTK.cpp b/gfx/src/gtk/nsRenderingContextGTK.cpp index 93f4d3890d54..dc249e24d3c9 100644 --- a/gfx/src/gtk/nsRenderingContextGTK.cpp +++ b/gfx/src/gtk/nsRenderingContextGTK.cpp @@ -775,10 +775,11 @@ NS_IMETHODIMP nsRenderingContextGTK::CreateDrawingSurface(nsRect *aBounds, aSurface = nsnull; return NS_ERROR_FAILURE; } - + g_return_val_if_fail (aBounds != NULL, NS_ERROR_FAILURE); g_return_val_if_fail ((aBounds->width > 0) && (aBounds->height > 0), NS_ERROR_FAILURE); + nsresult rv = NS_OK; nsDrawingSurfaceGTK *surf = new nsDrawingSurfaceGTK(); if (surf) @@ -786,12 +787,14 @@ NS_IMETHODIMP nsRenderingContextGTK::CreateDrawingSurface(nsRect *aBounds, NS_ADDREF(surf); if (!mGC) UpdateGC(); - surf->Init(mGC, aBounds->width, aBounds->height, aSurfFlags); + rv = surf->Init(mGC, aBounds->width, aBounds->height, aSurfFlags); + } else { + rv = NS_ERROR_FAILURE; } aSurface = (nsDrawingSurface)surf; - return NS_OK; + return rv; } NS_IMETHODIMP nsRenderingContextGTK::DestroyDrawingSurface(nsDrawingSurface aDS)