Fix error in UI_butstore_ API
If the `uiButStore` data was freed after the buttons/blocks were updated from previous instances (see `UI_block_update_from_old()`), e.g. by delaying that to the "afterfuncs" (`ui_apply_but_funcs_after()`), the data would get lost. As result, the button pointers that the API is supposed to keep valid would point to freed memory. This wasn't an issue so far since the API didn't happen to be used this way. That changes with the next commit.
This commit is contained in:
parent
c13aa95eda
commit
74fa8787d8
Notes:
blender-bot
2023-04-14 09:18:04 +02:00
Referenced by issue #75203, Crash when changing active keying set.
|
@ -647,6 +647,7 @@ void UI_butstore_free(uiBlock *block, uiButStore *bs_handle)
|
|||
}
|
||||
|
||||
BLI_freelistN(&bs_handle->items);
|
||||
BLI_assert(BLI_findindex(&block->butstore, bs_handle) != -1);
|
||||
BLI_remlink(&block->butstore, bs_handle);
|
||||
|
||||
MEM_freeN(bs_handle);
|
||||
|
@ -747,8 +748,7 @@ void UI_butstore_update(uiBlock *block)
|
|||
/* move this list to the new block */
|
||||
if (block->oldblock) {
|
||||
if (block->oldblock->butstore.first) {
|
||||
block->butstore = block->oldblock->butstore;
|
||||
BLI_listbase_clear(&block->oldblock->butstore);
|
||||
BLI_movelisttolist(&block->butstore, &block->oldblock->butstore);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue