Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender-addons.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGaia Clary <gaia.clary@machinimatrix.org>2021-09-03 14:03:31 +0300
committerGaia Clary <gaia.clary@machinimatrix.org>2021-09-06 14:58:43 +0300
commit32baafe44dc56edd1baf6e5a16b4439ded8238f2 (patch)
treeacf0576678f77f162c23aaac5d8af1022a2e6b26
parent87d1c3811f86e257c5721e60124002c0e4a15887 (diff)
T91111: possible out of range when iterating over Math Vis item list
While preparing T91111 i found an issue with out of date index after my recent changes. The problem is: bpy.context.window_manager.MathVisProp can be "0" even when the list is actually empty. This patch fixes the index issue, although the true cause might still be found elsewhere. there is more to fix, so this is only a first step to a complete fix. Reviewed By: campbellbarton Differential Revision: https://developer.blender.org/D12390
-rw-r--r--space_view3d_math_vis/draw.py8
-rw-r--r--space_view3d_math_vis/utils.py13
2 files changed, 14 insertions, 7 deletions
diff --git a/space_view3d_math_vis/draw.py b/space_view3d_math_vis/draw.py
index 0420044e..33f6a965 100644
--- a/space_view3d_math_vis/draw.py
+++ b/space_view3d_math_vis/draw.py
@@ -149,8 +149,12 @@ def draw_callback_view():
bgl.glDepthFunc(bgl.GL_LESS)
data_matrix, data_quat, data_euler, data_vector, data_vector_array = utils.console_math_data()
- active_index = settings.index
- active_key = prop_states[active_index].name if active_index >= 0 else None
+ if settings.index in range(0,len(prop_states)):
+ active_index = settings.index
+ active_key = prop_states[active_index].name
+ else:
+ active_index = -1
+ active_key = None
if data_vector:
coords = [tuple(vec.to_3d()) for vec in data_vector.values()]
diff --git a/space_view3d_math_vis/utils.py b/space_view3d_math_vis/utils.py
index 8174ee5d..a175dd5c 100644
--- a/space_view3d_math_vis/utils.py
+++ b/space_view3d_math_vis/utils.py
@@ -23,11 +23,14 @@ import bpy
def console_namespace():
import console_python
- get_consoles = console_python.get_console
- consoles = getattr(get_consoles, "consoles", None)
- if consoles:
- for console, stdout, stderr in get_consoles.consoles.values():
- return console.locals
+ for window in bpy.context.window_manager.windows:
+ for area in window.screen.areas:
+ if area.type == 'CONSOLE':
+ for region in area.regions:
+ if region.type == 'WINDOW':
+ console = console_python.get_console(hash(region))
+ if console:
+ return console[0].locals
return {}