-
Notifications
You must be signed in to change notification settings - Fork 493
reserved texpos range #3716
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
reserved texpos range #3716
Conversation
|
I almost lost in logic branches:) |
| auto dummy_surface = | ||
| DFSDL_CreateRGBSurfaceWithFormat(0, 0, 0, 32, SDL_PixelFormatEnum::SDL_PIXELFORMAT_RGBA32); | ||
| for (int32_t i = 0; i < ReservedRange::size; i++) { | ||
| add_texture(dummy_surface); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
at program close, DF will attempt to free all these textures. Is the refcount incremented somewhere so that it doesn't end up doing a double free?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
game will perform FreeSurface for entire textures.raws (i guess)... so every texture with refcount = 1 will be destroyed (here we destroy dummy)
our cached surfaces has refcount = 2 and it will be decrmented to 1..
then Texture::cleanup() will be called in Core shutdown sequence, there we will one more time call FreeSurface for our cached surfaces and finaly destroy it
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I note that we currently double free on exit with current code in 50.09-r3, so this is a real issue. I'll test to make sure this PR fixes that issue before merging, but otherwise this is looking pretty good
|
sorry for the conflicting changes in Textures.cpp -- |
|
There is still a double free going on here and DF is aborting when it frees the textures in its array. Could you double check the refcounting logic? commenting out the for loop in |
|
On a win there is no errors on close, they are visible only while debugging. That's why i missed that. |
|
could you possibly update this branch with latest changes from develop? |
Co-authored-by: Myk <myk.taylor@gmail.com>
23a32fa to
f434809
Compare
|
rebased onto develop |
This PR add
reserved rangefeature to dynamic texture module.Reserved range is a buffer in the
textures.rawsvector right after static game textures. Game will never wipes items of this range from the vector.Now
loadTilset(),loadTexture(),createTile(),createTileset()can receive additional optional parameterbool reservedwhich define target range (false by default, dynamic range).close #3709