[Bf-blender-cvs] [74fa8787d86] master: Fix error in UI_butstore_ API

Julian Eisel noreply at git.blender.org
Wed Apr 8 23:25:02 CEST 2020


Commit: 74fa8787d8640c0856f3192898b8ebeaa0d639ac
Author: Julian Eisel
Date:   Wed Apr 8 22:36:58 2020 +0200
Branches: master
https://developer.blender.org/rB74fa8787d8640c0856f3192898b8ebeaa0d639ac

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.

===================================================================

M	source/blender/editors/interface/interface_utils.c

===================================================================

diff --git a/source/blender/editors/interface/interface_utils.c b/source/blender/editors/interface/interface_utils.c
index a69837e9b51..67cb91a3cc4 100644
--- a/source/blender/editors/interface/interface_utils.c
+++ b/source/blender/editors/interface/interface_utils.c
@@ -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);
     }
   }



More information about the Bf-blender-cvs mailing list