Fix T49034: multi-drag crashes when UI forces exit
authorCampbell Barton <ideasman42@gmail.com>
Tue, 11 Jul 2017 09:07:37 +0000 (19:07 +1000)
committerCampbell Barton <ideasman42@gmail.com>
Tue, 11 Jul 2017 09:10:40 +0000 (19:10 +1000)
source/blender/editors/interface/interface_utils.c

index 636b7e4e9cedf24f99096f2a60cc6528387fb831..cf16cc9f50d01218f5fc99f661a3f75bee843b51 100644 (file)
@@ -380,6 +380,17 @@ uiButStore *UI_butstore_create(uiBlock *block)
 
 void UI_butstore_free(uiBlock *block, uiButStore *bs_handle)
 {
+       /* Workaround for button store being moved into new block,
+        * which then can't use the previous buttons state ('ui_but_update_from_old_block' fails to find a match),
+        * keeping the active button in the old block holding a reference to the button-state in the new block: see T49034.
+        *
+        * Ideally we would manage moving the 'uiButStore', keeping a correct state.
+        * All things considered this is the most straightforward fix - Campbell.
+        */
+       if (block != bs_handle->block && bs_handle->block != NULL) {
+               block = bs_handle->block;
+       }
+
        BLI_freelistN(&bs_handle->items);
        BLI_remlink(&block->butstore, bs_handle);