- Moderator
- #1
While working on an enhancement for Moving Pictures I came across a bug in the MediaPortal GUIImage class. Briefly, if a GUIImage has been assigned a property (i.e. #MyCoverArtwork) rather than a filename for it's <texture> field, each time the value of this property changes MediaPortal tries to unload the old image and load in the new image. The problem is that it executes the FreeResources() method after the "filename" variable has been changed. Which means that it attempts to release the texture for the NEW filename rather than the old. The old texture stays in memory indefinitely unless some class outside the GUITextureManager explicitly asks for it to be deallocated.
This in most cases is relatively harmless but in some cases this could cause an unnecessary amount of video memory to be used. This behavior also creates a problem if you try to preload a texture. If you were to preload a texture in a separate thread and then, when loading had completed, reassign the corresponding property to update the GUIImage object, the GUIImage would proceed to unload the just loaded texture, and then reload it again. Obviously not desirable behavior, this will accomplish nothing but slow down the GUI.
So based on this I have created a patch to correct this behavior. With this patch the GUIImage object will now clear the previous texture when a property is changed and then try to load the new texture if needed. Because it may also be desirable to load a texture into memory and have it persist until explicitly removed (similar to how skin textures are handled) I have also added a new Load() method in the GUITextureManager with an additional parameter to specify if the image being loaded should be persistent.
The patch is attached to this post and is based on SVN revision 20960. If anyone has any questions about this fix, feel free to PM me. If after reviewing the patch you find a problem, let me know and maybe I can make a revision.
This in most cases is relatively harmless but in some cases this could cause an unnecessary amount of video memory to be used. This behavior also creates a problem if you try to preload a texture. If you were to preload a texture in a separate thread and then, when loading had completed, reassign the corresponding property to update the GUIImage object, the GUIImage would proceed to unload the just loaded texture, and then reload it again. Obviously not desirable behavior, this will accomplish nothing but slow down the GUI.
So based on this I have created a patch to correct this behavior. With this patch the GUIImage object will now clear the previous texture when a property is changed and then try to load the new texture if needed. Because it may also be desirable to load a texture into memory and have it persist until explicitly removed (similar to how skin textures are handled) I have also added a new Load() method in the GUITextureManager with an additional parameter to specify if the image being loaded should be persistent.
The patch is attached to this post and is based on SVN revision 20960. If anyone has any questions about this fix, feel free to PM me. If after reviewing the patch you find a problem, let me know and maybe I can make a revision.