diff options
author | Julian Eisel <julian@blender.org> | 2021-11-04 14:10:58 +0300 |
---|---|---|
committer | Julian Eisel <julian@blender.org> | 2021-11-04 14:20:37 +0300 |
commit | 80a46955d8212f01b77215ab12d479d934e305f4 (patch) | |
tree | 538ddd4b47c195df8006456c046d6dce6bad1a20 /source/blender/windowmanager/WM_types.h | |
parent | bfb664b65de2c71ee3d85760ee5dcf83a7c9aa23 (diff) |
Fix T92501: Crash when dragging material assets over 3D View regions
Issue was that the context used for dropbox handling and polling didn't
match the one used for drawing the dropbox and generating the tooltip
text (which would determine the material slot under the cursor,
requiring context). The mismatch would happen with overlapping regions.
Actually, this patch includes two fixes, each fixing the crash itself:
* Store the context from handling & polling and restore it for drawing.
* Correct the hovered region lookup for drawing to account for overlayed
regions.
Note that to properly set up context for drawing, we should also account
for the operator context, which isn't done here, see
https://developer.blender.org/T92501#1247581.
Diffstat (limited to 'source/blender/windowmanager/WM_types.h')
-rw-r--r-- | source/blender/windowmanager/WM_types.h | 31 |
1 files changed, 22 insertions, 9 deletions
diff --git a/source/blender/windowmanager/WM_types.h b/source/blender/windowmanager/WM_types.h index 9f427a90353..27c8aa532f2 100644 --- a/source/blender/windowmanager/WM_types.h +++ b/source/blender/windowmanager/WM_types.h @@ -1030,6 +1030,27 @@ typedef char *(*WMDropboxTooltipFunc)(struct bContext *, const int xy[2], struct wmDropBox *drop); +typedef struct wmDragActiveDropState { + /** Informs which dropbox is activated with the drag item. + * When this value changes, the #draw_activate and #draw_deactivate dropbox callbacks are + * triggered. + */ + struct wmDropBox *active_dropbox; + + /** If `active_dropbox` is set, the area it successfully polled in. To restore the context of it + * as needed. */ + struct ScrArea *area_from; + /** If `active_dropbox` is set, the region it successfully polled in. To restore the context of + * it as needed. */ + struct ARegion *region_from; + + /** Text to show when a dropbox poll succeeds (so the dropbox itself is available) but the + * operator poll fails. Typically the message the operator set with + * CTX_wm_operator_poll_msg_set(). */ + const char *disabled_info; + bool free_disabled_info; +} wmDragActiveDropState; + typedef struct wmDrag { struct wmDrag *next, *prev; @@ -1045,15 +1066,7 @@ typedef struct wmDrag { float scale; int sx, sy; - /** Informs which dropbox is activated with the drag item. - * When this value changes, the #draw_activate and #draw_deactivate dropbox callbacks are - * triggered. - */ - struct wmDropBox *active_dropbox; - /* Text to show when the operator poll fails. Typically the message the - * operator set with CTX_wm_operator_poll_msg_set(). */ - const char *disabled_info; - bool free_disabled_info; + wmDragActiveDropState drop_state; unsigned int flags; |