Fix T103719: missing shortcuts info for some tool-settings
Tool settings can be accessed from both `tool_settings` &
`scene.tool_settings`.
As of [0] `scene.tool_settings` was used instead of `tool_settings`
causing the snap shortcut not to display.
Resolve by supporting variations of data-paths so both are detected.
[0]: 9a76dd2454
This commit is contained in:
@@ -1454,10 +1454,31 @@ static bool ui_but_event_property_operator_string(const bContext *C,
|
||||
}
|
||||
}
|
||||
|
||||
/* There may be multiple data-paths to the same properties,
|
||||
* support different variations so key bindings are properly detected no matter which are used.
|
||||
*/
|
||||
char *data_path_variations[2] = {nullptr};
|
||||
int data_path_variations_num = 0;
|
||||
|
||||
{
|
||||
char *data_path = WM_context_path_resolve_property_full(C, ptr, prop, prop_index);
|
||||
|
||||
/* Always iterate once, even if data-path isn't set. */
|
||||
data_path_variations[data_path_variations_num++] = data_path;
|
||||
|
||||
if (data_path) {
|
||||
if (STRPREFIX(data_path, "scene.tool_settings.")) {
|
||||
data_path_variations[data_path_variations_num++] = BLI_strdup(data_path + 6);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/* We have a data-path! */
|
||||
bool found = false;
|
||||
|
||||
for (int data_path_index = 0; data_path_index < data_path_variations_num && (found == false);
|
||||
data_path_index++) {
|
||||
const char *data_path = data_path_variations[data_path_index];
|
||||
if (data_path || (prop_enum_value_ok && prop_enum_value_id)) {
|
||||
/* Create a property to host the "data_path" property we're sending to the operators. */
|
||||
IDProperty *prop_path;
|
||||
@@ -1503,14 +1524,17 @@ static bool ui_but_event_property_operator_string(const bContext *C,
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
/* cleanup */
|
||||
IDP_FreeProperty(prop_path);
|
||||
}
|
||||
}
|
||||
|
||||
for (int data_path_index = 0; data_path_index < data_path_variations_num; data_path_index++) {
|
||||
char *data_path = data_path_variations[data_path_index];
|
||||
if (data_path) {
|
||||
MEM_freeN(data_path);
|
||||
}
|
||||
}
|
||||
|
||||
return found;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user