[Bf-blender-cvs] [0efa41e] master: Fix rare crash dragging number-buttons

Campbell Barton noreply at git.blender.org
Mon Dec 1 23:35:03 CET 2014


Commit: 0efa41e996aaf1f489e6f8f5395de04d98664834
Author: Campbell Barton
Date:   Mon Dec 1 23:30:54 2014 +0100
Branches: master
https://developer.blender.org/rB0efa41e996aaf1f489e6f8f5395de04d98664834

Fix rare crash dragging number-buttons

Could happen dragging shape-keys UIList & the lower slider at once.

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

M	source/blender/editors/include/UI_interface.h
M	source/blender/editors/interface/interface.c
M	source/blender/editors/interface/interface_utils.c

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

diff --git a/source/blender/editors/include/UI_interface.h b/source/blender/editors/include/UI_interface.h
index b479215..42f6737 100644
--- a/source/blender/editors/include/UI_interface.h
+++ b/source/blender/editors/include/UI_interface.h
@@ -1000,6 +1000,7 @@ void UI_butstore_free(uiBlock *block, uiButStore *bs);
 bool UI_butstore_is_valid(uiButStore *bs);
 bool UI_butstore_is_registered(uiBlock *block, uiBut *but);
 void UI_butstore_register(uiButStore *bs_handle, uiBut **but_p);
+bool UI_butstore_register_update(uiBlock *block, uiBut *but_dst, const uiBut *but_src);
 void UI_butstore_unregister(uiButStore *bs_handle, uiBut **but_p);
 
 
diff --git a/source/blender/editors/interface/interface.c b/source/blender/editors/interface/interface.c
index 93f5a8e..92017e7 100644
--- a/source/blender/editors/interface/interface.c
+++ b/source/blender/editors/interface/interface.c
@@ -723,6 +723,10 @@ static bool ui_but_update_from_old_block(const bContext *C, uiBlock *block, uiBu
 
 		ui_but_update_linklines(block, oldbut, but);
 
+		if (!BLI_listbase_is_empty(&block->butstore)) {
+			UI_butstore_register_update(block, oldbut, but);
+		}
+
 		/* move/copy string from the new button to the old */
 		/* needed for alt+mouse wheel over enums */
 		if (but->str != but->strdata) {
diff --git a/source/blender/editors/interface/interface_utils.c b/source/blender/editors/interface/interface_utils.c
index 854f176..6cd5f5a 100644
--- a/source/blender/editors/interface/interface_utils.c
+++ b/source/blender/editors/interface/interface_utils.c
@@ -390,6 +390,27 @@ void UI_butstore_unregister(uiButStore *bs_handle, uiBut **but_p)
 }
 
 /**
+ * Update the pointer for a registered button.
+ */
+bool UI_butstore_register_update(uiBlock *block, uiBut *but_dst, const uiBut *but_src)
+{
+	uiButStore *bs_handle;
+	bool found = false;
+
+	for (bs_handle = block->butstore.first; bs_handle; bs_handle = bs_handle->next) {
+		uiButStoreElem *bs_elem;
+		for (bs_elem = bs_handle->items.first; bs_elem; bs_elem = bs_elem->next) {
+			if (*bs_elem->but_p == but_src) {
+				*bs_elem->but_p = but_dst;
+				found = true;
+			}
+		}
+	}
+
+	return found;
+}
+
+/**
  * NULL all pointers, don't free since the owner needs to be able to inspect.
  */
 void UI_butstore_clear(uiBlock *block)




More information about the Bf-blender-cvs mailing list