Fix unreported: FileHandler drag-an-drop tooltip is generated in a wrong context
The tool-tip generated for FileHandler drag-n-drop may be obtained from a different context where the dropbox poll function is invoked, which could generated an incorrect tool-tip since FileHandlers are polled again in a wrong context. This can be solved by ensuring the same context is used, however the tool-tip could be drawn in different windows. To avoid undefined tool-tips , this generates the tool-tip in place when the dropbox poll function is invoked. Pull Request: https://projects.blender.org/blender/blender/pulls/125037
This commit is contained in:
committed by
Julian Eisel
parent
ceb61ac921
commit
682161283e
@@ -1271,6 +1271,8 @@ struct wmDragActiveDropState {
|
||||
*/
|
||||
const char *disabled_info;
|
||||
bool free_disabled_info;
|
||||
|
||||
std::string tooltip;
|
||||
};
|
||||
|
||||
struct wmDrag {
|
||||
|
||||
@@ -457,6 +457,8 @@ static wmDropBox *dropbox_active(bContext *C,
|
||||
|
||||
const wmOperatorCallContext opcontext = wm_drop_operator_context_get(drop);
|
||||
if (drop->ot && WM_operator_poll_context(C, drop->ot, opcontext)) {
|
||||
/* Get dropbox tooltip now, #wm_drag_draw_tooltip can use a different draw context. */
|
||||
drag->drop_state.tooltip = dropbox_tooltip(C, drag, event->xy, drop);
|
||||
CTX_store_set(C, nullptr);
|
||||
return drop;
|
||||
}
|
||||
@@ -519,6 +521,7 @@ static void wm_drop_update_active(bContext *C, wmDrag *drag, const wmEvent *even
|
||||
/* Update UI context, before polling so polls can query this context. */
|
||||
drag->drop_state.ui_context.reset();
|
||||
drag->drop_state.ui_context = wm_drop_ui_context_create(C);
|
||||
drag->drop_state.tooltip = "";
|
||||
|
||||
wmDropBox *drop_prev = drag->drop_state.active_dropbox;
|
||||
wmDropBox *drop = wm_dropbox_active(C, drag, event);
|
||||
@@ -1078,12 +1081,7 @@ static void wm_drag_draw_tooltip(bContext *C, wmWindow *win, wmDrag *drag, const
|
||||
}
|
||||
int iconsize = UI_ICON_SIZE;
|
||||
int padding = 4 * UI_SCALE_FAC;
|
||||
|
||||
std::string tooltip;
|
||||
if (drag->drop_state.active_dropbox) {
|
||||
tooltip = dropbox_tooltip(C, drag, xy, drag->drop_state.active_dropbox);
|
||||
}
|
||||
|
||||
std::string &tooltip = drag->drop_state.tooltip;
|
||||
const bool has_disabled_info = drag->drop_state.disabled_info &&
|
||||
drag->drop_state.disabled_info[0];
|
||||
if (tooltip.empty() && !has_disabled_info) {
|
||||
|
||||
Reference in New Issue
Block a user