# HG changeset patch # User bsmith@81767d24-ef19-dc11-ae90-00e081727c95 # Date 1336070648 0 # Node ID 043db6b221c2b10f54de8b7d355bafaaaf20abd6 # Parent 1b10b4534bc42408b9f67d69bea9dd032374da69 Cleanups on the icon creation code on OS/2. Make sure any temporary resources are destroyed. diff -r 1b10b4534bc4 -r 043db6b221c2 os2/dw.c --- a/os2/dw.c Thu May 03 17:45:57 2012 +0000 +++ b/os2/dw.c Thu May 03 18:44:08 2012 +0000 @@ -8907,7 +8907,7 @@ } /* Internal function to create an icon from an existing pixmap */ -HICN _create_icon(char *file, HPIXMAP src) +HICN _create_icon(HPIXMAP src) { HPIXMAP pntr = dw_pixmap_new(hwndApp, WinQuerySysValue(HWND_DESKTOP, SV_CXICON), WinQuerySysValue(HWND_DESKTOP, SV_CYICON), src->depth); HPIXMAP mask = dw_pixmap_new(hwndApp, pntr->width, pntr->height*2, 1); @@ -8954,6 +8954,7 @@ { char *file = alloca(strlen(filename) + 6); HPIXMAP src = alloca(sizeof(struct _hpixmap)); + HICN icon = 0; if(!file || !src) return 0; @@ -8977,14 +8978,25 @@ strcat(file, image_exts[z]); if(access(file, 04) == 0 && _load_bitmap_file(file, hwndApp, &src->hbm, &src->hdc, &src->hps, &src->width, &src->height, &src->depth)) - return _create_icon(file, src); + { + icon = _create_icon(src); + break; + } } - return 0; } else if(_load_bitmap_file(file, hwndApp, &src->hbm, &src->hdc, &src->hps, &src->width, &src->height, &src->depth)) - return _create_icon(file, src); + icon = _create_icon(src); + /* Free temporary resources if in use */ + if(icon) + { + GpiSetBitmap(src->hps, NULLHANDLE); + GpiDeleteBitmap(src->hbm); + GpiAssociate(src->hps, NULLHANDLE); + GpiDestroyPS(src->hps); + DevCloseDC(src->hdc); + } /* Otherwise fall back to the classic method */ - return WinLoadFileIcon((PSZ)file, FALSE); + return icon ? icon : WinLoadFileIcon((PSZ)file, FALSE); } /*