[ALL] Fix color picker frame not regenerating the preview texture after being closed#1781
[ALL] Fix color picker frame not regenerating the preview texture after being closed#1781SanyaSho wants to merge 4 commits intoValveSoftware:masterfrom
Conversation
… created texture handle CColorXYPreview panel is no longer trying to use decremented (invalid) texture handle from MaterialSystem
|
So, what I am seeing here are material and texture leaks. The panel creates a new texture and material with the exact same name, even if one already exists and never destroys them. (At least in my tests with GMod) Since they are procedural textures and materials, they will always have a refcount of at least 1 ( This panel also creates a new TextureID every time the panel is created, but never destroys it. ( |
Thank you for the review! I'll fix the TextureID leak soon. I don't actually see how I can fix the material leak without replacing the CMaterialReference with a raw pointer or adding a new function that will not increment the refcount like CTextureReference::InitProceduralTexture. |
5553618 to
624850f
Compare
CMaterialReference has a special Init function that creates the material using the same arguments and doesn't increment the refcount twice. The material is now properly cleared on exit.
Description
When CProceduralTexturePanel calls it's CleanUp function it decrements the current texture handle ref index value and since the texture name never[1][2] gets changed you're left with a invalid texture until you restart the game
This fix will make each texture created by CProceduralTexturePanel have it's own unique ID, it will also make sure that allocated TextureID is cleared and simplify the texture creation code.
Video demonstration of a bug:
colorpicker_bug.mp4
Fixed version:
colorpicker_nobug.mp4