Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'source/blender/editors/interface/interface.cc')
-rw-r--r--source/blender/editors/interface/interface.cc25
1 files changed, 21 insertions, 4 deletions
diff --git a/source/blender/editors/interface/interface.cc b/source/blender/editors/interface/interface.cc
index 8774a177c7d..d6719f0aa9f 100644
--- a/source/blender/editors/interface/interface.cc
+++ b/source/blender/editors/interface/interface.cc
@@ -1861,15 +1861,32 @@ bool ui_but_context_poll_operator_ex(bContext *C,
const wmOperatorCallParams *optype_params)
{
bool result;
+ int old_but_flag = 0;
- if (but && but->context) {
- CTX_store_set(C, but->context);
+ if (but) {
+ old_but_flag = but->flag;
+
+ /* Temporarily make this button override the active one, in case the poll acts on the active
+ * button. */
+ const_cast<uiBut *>(but)->flag |= UI_BUT_ACTIVE_OVERRIDE;
+
+ if (but->context) {
+ CTX_store_set(C, but->context);
+ }
}
result = WM_operator_poll_context(C, optype_params->optype, optype_params->opcontext);
- if (but && but->context) {
- CTX_store_set(C, nullptr);
+ if (but) {
+ BLI_assert_msg((but->flag & ~UI_BUT_ACTIVE_OVERRIDE) ==
+ (old_but_flag & ~UI_BUT_ACTIVE_OVERRIDE),
+ "Operator polls shouldn't change button flags");
+
+ const_cast<uiBut *>(but)->flag = old_but_flag;
+
+ if (but->context) {
+ CTX_store_set(C, nullptr);
+ }
}
return result;