Hi, Thank you Scuri. Glad to know. Best regards, Ranier Vilela ________________________________________ De: Antonio Scuri <antonio.sc...@gmail.com> Enviado: terça-feira, 20 de fevereiro de 2018 21:53 Para: IUP discussion list. Assunto: Re: [Iup-users] IUP 3.24 RESOURCE_LEAK (iupwin_menu.c)
Hi, Just fixed and committed to SVN. Does not solves the problem for cursors and icons. But it does for images, which is more important because we now draw those images manually when using IupDrawImage in IupFlat controls. Although the system documentation in GTK and Windows say that it is ok not to release those resources. When the application is closed they will be automatically deleted by the system. Best, Scuri 2018-02-20 9:54 GMT-03:00 Ranier VF <ranier_...@hotmail.com<mailto:ranier_...@hotmail.com>>: Hi, In relation this bug, some consideration? Best regards, Ranier Vilela ________________________________________ De: Ranier VF <ranier_...@hotmail.com<mailto:ranier_...@hotmail.com>> Enviado: segunda-feira, 29 de janeiro de 2018 12:01 Para: IUP discussion list. Assunto: Re: [Iup-users] IUP 3.24 RESOURCE_LEAK (iupwin_menu.c) Hi, Check this patch, if is ok? --- a\src\iup_image.c Mon Jan 29 09:17:08 2018 +++ b\src\iup_image.c Mon Jan 29 09:58:56 2018 @@ -613,11 +613,11 @@ void* iupImageGetImage(const char* name, Ihandle* ih_parent, int make_inactive) { - char cache_name[100] = "_IUPIMAGE_IMAGE"; + char cache_name[128] = "_IUPIMAGE_IMAGE"; + const char* native_name = NULL; char* bgcolor; void* handle; Ihandle *ih; - int bg_concat = 0; if (!name) return NULL; @@ -625,65 +625,46 @@ ih = iImageGetImageFromName(name); if (!ih) { - const char* native_name = NULL; - - /* Check in the system resources. */ - handle = iupdrvImageLoad(name, IUPIMAGE_IMAGE); - if (handle) - return handle; - /* Check in the stock images. */ iImageStockGet(name, &ih, &native_name); - if (native_name) - { - handle = iupdrvImageLoad(native_name, IUPIMAGE_IMAGE); - if (handle) - return handle; - } - if (!ih) return NULL; } - handle = iupAttribGet(ih, "_IUPSTOCK_LOAD_HANDLE"); if (handle) + { return handle; - - bgcolor = iupAttribGet(ih, "BGCOLOR"); - if (ih_parent && !bgcolor) - bgcolor = IupGetAttribute(ih_parent, "BGCOLOR"); /* Use IupGetAttribute to use inheritance and native implementation */ + } if (make_inactive) strcat(cache_name, "_INACTIVE"); + bgcolor = iupAttribGet(ih, "BGCOLOR"); + if (ih_parent && !bgcolor) + bgcolor = IupGetAttribute(ih_parent, "BGCOLOR"); /* Use IupGetAttribute to use inheritance and native implementation */ if (iupAttribGet(ih, "_IUP_BGCOLOR_DEPEND") && bgcolor) { strcat(cache_name, "("); strcat(cache_name, bgcolor); strcat(cache_name, ")"); - bg_concat = 1; } - + /* Check for an already created native image */ handle = (void*)iupAttribGet(ih, cache_name); if (handle) return handle; - if (ih_parent && iupAttribGetStr(ih_parent, "FLAT_ALPHA")) - iupAttribSet(ih, "FLAT_ALPHA", "1"); - - /* Creates the native image */ - handle = iupdrvImageCreateImage(ih, bgcolor, make_inactive); - - if (ih_parent && iupAttribGetStr(ih_parent, "FLAT_ALPHA")) - iupAttribSet(ih, "FLAT_ALPHA", NULL); - - if (iupAttribGet(ih, "_IUP_BGCOLOR_DEPEND") && bgcolor && !bg_concat) /* _IUP_BGCOLOR_DEPEND could be set during creation */ + /* Check in the system resources. */ + handle = iupdrvImageLoad(name, IUPIMAGE_IMAGE); + if (!handle && native_name) { - strcat(cache_name, "("); - strcat(cache_name, bgcolor); - strcat(cache_name, ")"); + handle = iupdrvImageLoad(native_name, IUPIMAGE_IMAGE); + if (!handle) + return NULL; } + + if (ih_parent && iupAttribGetStr(ih_parent, "FLAT_ALPHA")) + iupAttribSet(ih_image, "FLAT_ALPHA", NULL); /* save the native image in the cache */ iupAttribSet(ih, cache_name, (char*)handle); Best, Ranier Vilela ________________________________________ De: Ranier VF <ranier_...@hotmail.com<mailto:ranier_...@hotmail.com>> Enviado: segunda-feira, 29 de janeiro de 2018 11:11 Para: IUP discussion list. Assunto: Re: [Iup-users] IUP 3.24 RESOURCE_LEAK (iupwin_menu.c) Hi, Really the patch submitted is not correct, but, the problem persists. iupwin_menu leaks the image handler. in (iup_image.c), function: iupImageGetImage if function iImageGetImageFromName fail, is executed this: handle = iupdrvImageLoad(name, IUPIMAGE_IMAGE); if (handle) return handle; iupdrvImageLoad dot not store handle in the cache, in this way, iupwin_menu.c still leaks. Best regards, Ranier Vilela ________________________________________ De: Antonio Scuri <antonio.sc...@gmail.com<mailto:antonio.sc...@gmail.com>> Enviado: sexta-feira, 26 de janeiro de 2018 19:44 Para: IUP discussion list. Assunto: Re: [Iup-users] IUP 3.24 RESOURCE_LEAK (iupwin_menu.c) Those DeleteObject(hBitmap*) can not be called. They are stored in a cache inside the IupImage, they will be released later when the image is destroyed. Best, Scuri 2018-01-24 22:30 GMT-02:00 Ranier VF <ranier_...@hotmail.com<mailto:ranier_...@hotmail.com><mailto:ranier_...@hotmail.com<mailto:ranier_...@hotmail.com>>>: Hi, Issue found by Coverity Scan. CID 259189 (#1-2 of 2): Resource leak (RESOURCE_LEAK) --- a\src\win\iupwin_menu.c Mon Dec 11 14:52:42 2017 +++ b\src\win\iupwin_menu.c Wed Jan 24 22:26:33 2018 @@ -431,9 +431,13 @@ hBitmapChecked = hBitmapUnchecked; SetMenuItemBitmaps((HMENU)ih->handle, (UINT)ih->serial, MF_BYCOMMAND, hBitmapUnchecked, hBitmapChecked); - winMenuUpdateBar(ih); + if (impress) + { + DeleteObject(hBitmapChecked); + } + return 1; } @@ -450,8 +454,13 @@ hBitmapChecked = hBitmapUnchecked; SetMenuItemBitmaps((HMENU)ih->handle, (UINT)ih->serial, MF_BYCOMMAND, hBitmapUnchecked, hBitmapChecked); - winMenuUpdateBar(ih); + + if (value) + { + DeleteObject(hBitmapChecked); + } + DeleteObject(hBitmapunChecked); return 1; } Best. Ranier Vilela ------------------------------------------------------------------------------ Check out the vibrant tech community on one of the world's most engaging tech sites, Slashdot.org! http://sdm.link/slashdot _______________________________________________ Iup-users mailing list Iup-users@lists.sourceforge.net<mailto:Iup-users@lists.sourceforge.net><mailto:Iup-users@lists.sourceforge.net<mailto:Iup-users@lists.sourceforge.net>> https://lists.sourceforge.net/lists/listinfo/iup-users ------------------------------------------------------------------------------ Check out the vibrant tech community on one of the world's most engaging tech sites, Slashdot.org! http://sdm.link/slashdot _______________________________________________ Iup-users mailing list Iup-users@lists.sourceforge.net<mailto:Iup-users@lists.sourceforge.net> https://lists.sourceforge.net/lists/listinfo/iup-users ------------------------------------------------------------------------------ Check out the vibrant tech community on one of the world's most engaging tech sites, Slashdot.org! http://sdm.link/slashdot _______________________________________________ Iup-users mailing list Iup-users@lists.sourceforge.net<mailto:Iup-users@lists.sourceforge.net> https://lists.sourceforge.net/lists/listinfo/iup-users ------------------------------------------------------------------------------ Check out the vibrant tech community on one of the world's most engaging tech sites, Slashdot.org! http://sdm.link/slashdot _______________________________________________ Iup-users mailing list Iup-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/iup-users