Fix a potential leak of a drawing surface. Fix a definite and frequent leak of graphics contexts. r=Pavlov.

This commit is contained in:
bruce%cybersight.com 2000-03-16 06:53:59 +00:00
Родитель 93ec940c64
Коммит 5d6b5ce6dd
1 изменённых файлов: 11 добавлений и 1 удалений

Просмотреть файл

@ -125,7 +125,12 @@ NS_IMETHODIMP nsRenderingContextGTK::Init(nsIDeviceContext* aContext,
{
GtkWidget *w = (GtkWidget *) aWindow->GetNativeData(NS_NATIVE_WIDGET);
if (!w) return NS_ERROR_NULL_POINTER;
if (!w)
{
delete mSurface;
mSurface = nsnull;
return NS_ERROR_NULL_POINTER;
}
win = gdk_pixmap_new(nsnull,
w->allocation.width,
@ -139,6 +144,11 @@ NS_IMETHODIMP nsRenderingContextGTK::Init(nsIDeviceContext* aContext,
mOffscreenSurface = mSurface;
NS_ADDREF(mSurface);
// aWindow->GetNativeData() ref'd the gc.
// only Win32 has a FreeNativeData() method.
// so do this manually here.
gdk_gc_unref(gc);
}
return (CommonInit());
}