[Bf-blender-cvs] [987e9e2145f] master: Fix T84469: Online manual raises an exception with key-map options

Campbell Barton noreply at git.blender.org
Thu Jan 7 13:37:25 CET 2021


Commit: 987e9e2145fd31e9a3f763819b0e942ccd93bb65
Author: Campbell Barton
Date:   Thu Jan 7 23:24:23 2021 +1100
Branches: master
https://developer.blender.org/rB987e9e2145fd31e9a3f763819b0e942ccd93bb65

Fix T84469: Online manual raises an exception with key-map options

Report an error instead of raising a Python exception.

Currently these properties aren't written to the manual
so it's best to show an error.

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

M	release/scripts/startup/bl_operators/wm.py

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

diff --git a/release/scripts/startup/bl_operators/wm.py b/release/scripts/startup/bl_operators/wm.py
index 350d9391acf..bef3e5d4384 100644
--- a/release/scripts/startup/bl_operators/wm.py
+++ b/release/scripts/startup/bl_operators/wm.py
@@ -974,7 +974,7 @@ class WM_OT_path_open(Operator):
         return {'FINISHED'}
 
 
-def _wm_doc_get_id(doc_id, do_url=True, url_prefix=""):
+def _wm_doc_get_id(doc_id, do_url=True, url_prefix="", report=None):
 
     def operator_exists_pair(a, b):
         # Not fast, this is only for docs.
@@ -1025,6 +1025,11 @@ def _wm_doc_get_id(doc_id, do_url=True, url_prefix=""):
                 # Check class for dynamically registered types.
                 rna_class = bpy.types.PropertyGroup.bl_rna_get_subclass_py(class_name)
 
+            if rna_class is None:
+                if report is not None:
+                    report({'ERROR'}, iface_("Type \"%s\" can not be found") % class_name)
+                return None
+
             # Detect if this is a inherited member and use that name instead.
             rna_parent = rna_class.bl_rna
             rna_prop = rna_parent.properties.get(class_prop)
@@ -1084,9 +1089,9 @@ class WM_OT_doc_view_manual(Operator):
                 return url
 
     def execute(self, _context):
-        rna_id = _wm_doc_get_id(self.doc_id, do_url=False)
+        rna_id = _wm_doc_get_id(self.doc_id, do_url=False, report=self.report)
         if rna_id is None:
-            return {'PASS_THROUGH'}
+            return {'CANCELLED'}
 
         url = self._lookup_rna_url(rna_id)
 
@@ -1118,9 +1123,9 @@ class WM_OT_doc_view(Operator):
         _prefix = ("https://docs.blender.org/api/master")
 
     def execute(self, _context):
-        url = _wm_doc_get_id(self.doc_id, do_url=True, url_prefix=self._prefix)
+        url = _wm_doc_get_id(self.doc_id, do_url=True, url_prefix=self._prefix, report=self.report)
         if url is None:
-            return {'PASS_THROUGH'}
+            return {'CANCELLED'}
 
         import webbrowser
         webbrowser.open(url)



More information about the Bf-blender-cvs mailing list