[Bf-blender-cvs] [3b2a6bf8e8f] master: UI: Don't show Windows file association operator in search on other OSes

Julian Eisel noreply at git.blender.org
Fri Jul 30 16:44:13 CEST 2021


Commit: 3b2a6bf8e8f87c2d1a8927637c562502af8083b9
Author: Julian Eisel
Date:   Fri Jul 30 16:27:52 2021 +0200
Branches: master
https://developer.blender.org/rB3b2a6bf8e8f87c2d1a8927637c562502af8083b9

UI: Don't show Windows file association operator in search on other OSes

The Windows-specific "Register File Association" operator would show in
the search menu of other platforms. Decided to not disable it at
compile-time, like we do it with "Toggle System Console" (another
Windows-only operator), because that would require workarounds for the
translation tools. Instead the operator poll function always returns
false on unsupported platforms now.

===================================================================

M	source/blender/editors/space_userpref/userpref_ops.c

===================================================================

diff --git a/source/blender/editors/space_userpref/userpref_ops.c b/source/blender/editors/space_userpref/userpref_ops.c
index 79f5d1818cb..63506678b70 100644
--- a/source/blender/editors/space_userpref/userpref_ops.c
+++ b/source/blender/editors/space_userpref/userpref_ops.c
@@ -197,6 +197,17 @@ static void PREFERENCES_OT_asset_library_remove(wmOperatorType *ot)
 /** \name Associate File Type Operator (Windows only)
  * \{ */
 
+static bool associate_blend_poll(bContext *C)
+{
+#ifdef WIN32
+  UNUSED_VARS(C);
+  return true;
+#else
+  CTX_wm_operator_poll_msg_set(C, "Windows-only operator");
+  return false;
+#endif
+}
+
 static int associate_blend_exec(bContext *UNUSED(C), wmOperator *op)
 {
 #ifdef WIN32
@@ -212,7 +223,8 @@ static int associate_blend_exec(bContext *UNUSED(C), wmOperator *op)
     return OPERATOR_CANCELLED;
   }
 #else
-  BKE_report(op->reports, RPT_WARNING, "Operator Not supported");
+  UNUSED_VARS(op);
+  BLI_assert_unreachable();
   return OPERATOR_CANCELLED;
 #endif
 }
@@ -226,6 +238,7 @@ static void PREFERENCES_OT_associate_blend(struct wmOperatorType *ot)
 
   /* api callbacks */
   ot->exec = associate_blend_exec;
+  ot->poll = associate_blend_poll;
 }
 
 /** \} */



More information about the Bf-blender-cvs mailing list