Fix T95394: Crash when dragging from location of just cleared asset

In Blender buttons are recreated over redraws, except of the active
button which is kept alive, and replaces the new version of itself in
the new redraw. In order to do that, the button needs to be recognized.
This process of recognizing and matching buttons from different redraws
isn't always bullet-proof. That's okay-ish, but we have to make sure
that the relevant data of the old active button is updated with the
newest data.

Here the matching would go wrong, and the new active button was
recognized as the old active button, which was in fact removed when the
asset was cleared. This patch makes sure the image buffer attached to
the buttons is updated when buttons were recognized as matching.

Note that the dragging will still use the wrong data-block, this will be
fixed in the following commit.
This commit is contained in:
2022-05-31 12:03:33 +02:00
parent 344a8fb3d4
commit 75ef51cc80

View File

@@ -930,6 +930,9 @@ static void ui_but_update_old_active_from_new(uiBut *oldbut, uiBut *but)
if (but->dragpoin && (but->dragflag & UI_BUT_DRAGPOIN_FREE)) {
SWAP(void *, but->dragpoin, oldbut->dragpoin);
}
if (but->imb) {
SWAP(ImBuf *, but->imb, oldbut->imb);
}
/* NOTE: if layout hasn't been applied yet, it uses old button pointers... */
}