Closed alikin12 closed 3 months ago
Hello, thank you for the contribution! I'm not sure I understand what this change accomplishes, or how it's related to issue #958. I am trying to switch between projects with and without your change and I do not notice anything different. Can you explain how this fixes an issue?
Hello. First of all I want to thank you for your great work and the effort you and all other people who are involved in this project put into pixelorama. It's a very nice tool.
Regarding the issue and my fix I try to explain how to reproduce the issue and how the change fixes it:
Reproducing issue:
All this happens only when project was saved and reloaded. It does not happen without the reloading step.
Fix: The issue appears because when a project is loaded, the brushes are added in the open_pxo_file method by add_project_brush. After that the change_project method is called which should clear all brushed and repopulate it again with the project ones. Without the fix the old brushes are not cleared directly (I think because queue_free() takes effect only on the next frame) and when the new brushes are added, the index which is set by get_index() is set to the wrong value as the old brushes still exist and the index has now an offset of the old brushs count. When switching the tool from another tool back to pencil, the brush with the wrong (not existing) index is tried to selected. As the child with this index does not exist, it fails and the default brush is selected.
Hope that helps :)
This should fix issue #958 (reset custom brush when switch another tool) by removing the childs safely from BrushPopup when project data is cleared.