Don't crash when CurrentSurface() or GetDC() return null. b=391243 r+sr+a=vladimir

This commit is contained in:
mats.palmgren@bredband.net 2007-08-14 02:47:37 -07:00
parent bbe0108c14
commit c366407693

View File

@ -80,11 +80,14 @@ static PRLogModuleInfo *gFontLog = PR_NewLogModule("winfonts");
struct DCFromContext {
DCFromContext(gfxContext *aContext) {
HDC dc = NULL;
nsRefPtr<gfxASurface> aSurface = aContext->CurrentSurface();
if (aSurface->GetType() == gfxASurface::SurfaceTypeWin32) {
NS_ASSERTION(aSurface, "DCFromContext: null surface");
if (aSurface && aSurface->GetType() == gfxASurface::SurfaceTypeWin32) {
dc = static_cast<gfxWindowsSurface*>(aSurface.get())->GetDC();
needsRelease = PR_FALSE;
} else {
}
if (!dc) {
dc = GetDC(NULL);
needsRelease = PR_TRUE;
}