/*********************************************************************** * DeleteObject (GDI32.@) */ BOOL WINAPI DeleteObject( HGDIOBJ obj ) { /* Check if object is valid */ GDIOBJHDR * header; if (HIWORD(obj)) return FALSE; if (!(header = GDI_GetObjPtr( obj, MAGIC_DONTCARE ))) return FALSE; if (!(header->wMagic & OBJECT_NOSYSTEM) && (header->wMagic >= FIRST_MAGIC) && (header->wMagic <= LAST_MAGIC)) { TRACE("Preserving system object %04x\n", obj); GDI_ReleaseObj( obj ); return TRUE; } if (header->dwCount) { TRACE("delayed for %04x because object in use, count %ld\n", obj, header->dwCount ); header->dwCount |= 0x80000000; /* mark for delete */ GDI_ReleaseObj( obj ); return TRUE; } TRACE("%04x\n", obj ); /* Delete object */ switch(GDIMAGIC(header->wMagic)) { case PEN_MAGIC: return GDI_FreeObject( obj, header ); case BRUSH_MAGIC: return BRUSH_DeleteObject( obj, (BRUSHOBJ*)header ); case FONT_MAGIC: return FONT_DeleteObject( obj, (FONTOBJ*)header ); case PALETTE_MAGIC: return PALETTE_DeleteObject(obj,(PALETTEOBJ*)header); case BITMAP_MAGIC: return BITMAP_DeleteObject( obj, (BITMAPOBJ*)header); case REGION_MAGIC: return REGION_DeleteObject( obj, (RGNOBJ*)header ); case DC_MAGIC: GDI_ReleaseObj( obj ); return DeleteDC(obj); case 0 : WARN("Already deleted\n"); break; default: WARN("Unknown magic number (%04x)\n",GDIMAGIC(header->wMagic)); } GDI_ReleaseObj( obj ); return FALSE; }
/*********************************************************************** * BITMAP_DeleteObject */ static BOOL BITMAP_DeleteObject( HGDIOBJ handle, void *obj ) { BITMAPOBJ * bmp = obj; if (bmp->funcs && bmp->funcs->pDeleteBitmap) bmp->funcs->pDeleteBitmap( handle ); HeapFree( GetProcessHeap(), 0, bmp->bitmap.bmBits ); if (bmp->dib) { DIBSECTION *dib = bmp->dib; if (dib->dsBm.bmBits) { if (dib->dshSection) { SYSTEM_INFO SystemInfo; GetSystemInfo( &SystemInfo ); UnmapViewOfFile( (char *)dib->dsBm.bmBits - (dib->dsOffset % SystemInfo.dwAllocationGranularity) ); } else if (!dib->dsOffset) VirtualFree(dib->dsBm.bmBits, 0L, MEM_RELEASE ); } HeapFree(GetProcessHeap(), 0, dib); bmp->dib = NULL; if (bmp->segptr_bits) { /* free its selector array */ WORD sel = SELECTOROF(bmp->segptr_bits); WORD count = (GetSelectorLimit16(sel) / 0x10000) + 1; int i; for (i = 0; i < count; i++) FreeSelector16(sel + (i << __AHSHIFT)); } HeapFree(GetProcessHeap(), 0, bmp->color_table); } return GDI_FreeObject( handle, obj ); }
/*********************************************************************** * FONT_DeleteObject * */ static BOOL FONT_DeleteObject(HGDIOBJ hfont, FONTOBJ *fontobj) { WineEngDestroyFontInstance( hfont ); return GDI_FreeObject( hfont, fontobj ); }