Commit: 0ff7d21c27957b4f4a9f02c59b458cdd6beeb06b
Author: Campbell Barton
Date:   Thu Oct 15 16:51:18 2020 +1100
Branches: blender-v2.83-release
https://developer.blender.org/rB0ff7d21c27957b4f4a9f02c59b458cdd6beeb06b

Fix T81520: Crash setting the Cycles device from Python

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

M       intern/cycles/blender/addon/properties.py

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

diff --git a/intern/cycles/blender/addon/properties.py 
b/intern/cycles/blender/addon/properties.py
index c91e210bbd8..39650801584 100644
--- a/intern/cycles/blender/addon/properties.py
+++ b/intern/cycles/blender/addon/properties.py
@@ -1577,8 +1577,13 @@ class CyclesPreferences(bpy.types.AddonPreferences):
     # For backwards compatibility, only returns CUDA and OpenCL but still
     # refreshes all devices.
     def get_devices(self, compute_device_type=''):
+        import _cycles
+        # Ensure `self.devices` is not re-allocated when the second call to
+        # get_devices_for_type is made, freeing items from the first list.
+        for device_type in ('CUDA', 'OPTIX', 'OPENCL'):
+            self.update_device_entries(_cycles.available_devices(device_type))
+
         cuda_devices = self.get_devices_for_type('CUDA')
-        self.get_devices_for_type('OPTIX')
         opencl_devices = self.get_devices_for_type('OPENCL')
         return cuda_devices, opencl_devices

_______________________________________________
Bf-blender-cvs mailing list
Bf-blender-cvs@blender.org
https://lists.blender.org/mailman/listinfo/bf-blender-cvs

Reply via email to