From 291f2ce42f45a33e650b0bfdbfaf8c5cd2516af0 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Fri, 23 Feb 2024 14:57:00 +1100 Subject: [PATCH] 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. --- .../blender/editors/space_buttons/buttons_ops.cc | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/source/blender/editors/space_buttons/buttons_ops.cc b/source/blender/editors/space_buttons/buttons_ops.cc index f554f0d5a7a..97d7060c6bb 100644 --- a/source/blender/editors/space_buttons/buttons_ops.cc +++ b/source/blender/editors/space_buttons/buttons_ops.cc @@ -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";