System Information
Operating system: Windows-10-10.0.19044-SP0 64 Bits
Graphics card: NVIDIA GeForce RTX 2070 SUPER/PCIe/SSE2 NVIDIA Corporation 4.5.0 NVIDIA 516.01
Blender Version
Broken: version: 3.4.0 Alpha, branch: master, commit date: 2022-10-21 00:31, hash: rBdc09cc13ea49
Worked: 3.3.0 and before
Short description of error
When an empty list of positions is used in batch_for_shader pos property (for example batch_for_shader(shader, 'LINE_STRIP', {"pos": []}) modules\gpu_extras\batch.py throws errors.
Exact steps for others to reproduce the error
- open the attached .blend, it contains a slightly modified version of the operator_modal_draw.py (Modal Draw) python template;
- it's modified to add points to self.mouse_path on left mouse click instead of mousemove, this way self.mouse_path starts empty;
- run the code to register the operator;
- run the operator (Simple Modal View3D Operator)
- notice errors in console:
mouse points 0
Traceback (most recent call last):
File "D:\temp\del\batch_for_shader_issue.blend\Text", line 21, in draw_callback_px
File "c:\Program Files\Blender Foundation\blender-3.4.0-alpha-scripts\3.4\scripts\modules\gpu_extras\batch.py", line 62, in batch_for_shader
attr_len = recommended_attr_len(name)
File "c:\Program Files\Blender Foundation\blender-3.4.0-alpha-scripts\3.4\scripts\modules\gpu_extras\batch.py", line 37, in recommended_attr_len
item = content[attr_name][0]
IndexError: list index out of range- after the first click when a coordinate is added to self.mouse_path errors disappear;
- running the same code in 3.3 doesn't produce errors