UI: prevent file-selector buttons operating on non-editable properties

While relatively harmless, it's annoying if a user spends time to select
a file only to find the property can't be changed.
This commit is contained in:
Campbell Barton
2024-02-23 14:57:00 +11:00
parent f726779d76
commit 291f2ce42f

View File

@@ -301,6 +301,20 @@ static int file_browse_invoke(bContext *C, wmOperator *op, const wmEvent *event)
return OPERATOR_CANCELLED;
}
{
const char *info;
if (!RNA_property_editable_info(&ptr, prop, &info)) {
if (info[0]) {
BKE_reportf(op->reports, RPT_ERROR, "Property is not editable: %s", info);
}
else {
BKE_report(op->reports, RPT_ERROR, "Property is not editable");
}
MEM_freeN(path);
return OPERATOR_CANCELLED;
}
}
PropertyRNA *prop_relpath;
const char *path_prop = RNA_struct_find_property(op->ptr, "directory") ? "directory" :
"filepath";