Changeset View
Changeset View
Standalone View
Standalone View
space_view3d_math_vis/utils.py
| Show First 20 Lines • Show All 44 Lines • ▼ Show 20 Lines | class VarStates: | ||||
| @staticmethod | @staticmethod | ||||
| def store_states(): | def store_states(): | ||||
| # Store the display states, called upon unregister the Add-on | # Store the display states, called upon unregister the Add-on | ||||
| # This is useful when you press F8 to reload the Addons. | # This is useful when you press F8 to reload the Addons. | ||||
| # Then this function preserves the display states of the | # Then this function preserves the display states of the | ||||
| # console variables. | # console variables. | ||||
| state_props = bpy.context.window_manager.MathVisStatePropList | state_props = bpy.context.window_manager.MathVisStatePropList | ||||
| variables = get_math_data() | variables = get_math_data() | ||||
| for index, state_prop in reversed(list(enumerate(state_props))): | |||||
campbellbarton: This loop should be reversed, since removing multiple items won't work as expected if there are… | |||||
| if state_prop.name not in variables: | |||||
| # Variable has been removed from console | |||||
| state_props.remove(index) | |||||
| for key, ktype in variables.items(): | for key, ktype in variables.items(): | ||||
| if key and key not in state_props: | if key and key not in state_props: | ||||
| prop = state_props.add() | prop = state_props.add() | ||||
| prop.name = key | prop.name = key | ||||
| prop.ktype = ktype.__name__ | prop.ktype = ktype.__name__ | ||||
| prop.state = [True, False] | prop.state = [True, False] | ||||
| @staticmethod | @staticmethod | ||||
| ▲ Show 20 Lines • Show All 125 Lines • Show Last 20 Lines | |||||
This loop should be reversed, since removing multiple items won't work as expected if there are more than one index to remove.