diff --git a/source/blender/editors/space_buttons/buttons_ops.cc b/source/blender/editors/space_buttons/buttons_ops.cc index 2fe01d9e10d..625b9ada241 100644 --- a/source/blender/editors/space_buttons/buttons_ops.cc +++ b/source/blender/editors/space_buttons/buttons_ops.cc @@ -24,6 +24,7 @@ #include "BKE_context.hh" #include "BKE_library.hh" #include "BKE_main.hh" +#include "BKE_path_templates.hh" #include "BKE_report.hh" #include "BKE_screen.hh" @@ -302,6 +303,18 @@ static wmOperatorStatus file_browse_invoke(bContext *C, wmOperator *op, const wm path = RNA_property_string_get_alloc(&ptr, prop, nullptr, 0, nullptr); + if ((RNA_property_flag(prop) & PROP_PATH_SUPPORTS_TEMPLATES) != 0) { + const Scene *scene = CTX_data_scene(C); + const blender::Vector errors = BKE_path_apply_template( + path, + FILE_MAX, + BKE_build_template_variables(BKE_main_blendfile_path_from_global(), &scene->r)); + if (!errors.is_empty()) { + BKE_report_path_template_errors(op->reports, RPT_ERROR, path, errors); + return OPERATOR_CANCELLED; + } + } + /* Useful yet irritating feature, Shift+Click to open the file * Alt+Click to browse a folder in the OS's browser. */ if (event->modifier & (KM_SHIFT | KM_ALT)) {