[Bf-blender-cvs] [964bb28e21b] blender2.8: gpu.types.GPUOffscreen.py example file: Delete the reference of the previous shader.

mano-wii noreply at git.blender.org
Fri Sep 21 17:38:36 CEST 2018


Commit: 964bb28e21bdaf3ab93e4665a012d717c5d5a89a
Author: mano-wii
Date:   Fri Sep 21 12:36:38 2018 -0300
Branches: blender2.8
https://developer.blender.org/rB964bb28e21bdaf3ab93e4665a012d717c5d5a89a

gpu.types.GPUOffscreen.py example file: Delete the reference of the previous shader.

Strange that the `bpy.utils.register_class` utility does not remove the reference of the class with same name.

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

M	doc/python_api/examples/gpu.types.GPUOffScreen.py

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

diff --git a/doc/python_api/examples/gpu.types.GPUOffScreen.py b/doc/python_api/examples/gpu.types.GPUOffScreen.py
index b7f11b94a11..4f601ee7ef1 100644
--- a/doc/python_api/examples/gpu.types.GPUOffScreen.py
+++ b/doc/python_api/examples/gpu.types.GPUOffScreen.py
@@ -241,8 +241,11 @@ class VIEW3D_OT_draw_offscreen(bpy.types.Operator):
 
 
 def register():
-    if hasattr(bpy.types, "VIEW3D_OT_draw_offscreen"):
-        del VIEW3D_OT_draw_offscreen.global_shader
+    try:
+        cls = getattr(bpy.types, "VIEW3D_OT_draw_offscreen")
+        del cls.global_shader
+    except:
+        pass
 
     shader = gpu.types.GPUShader(g_imageVertSrc, g_imageFragSrc)
     VIEW3D_OT_draw_offscreen.global_shader = shader



More information about the Bf-blender-cvs mailing list