Fix #137507: collection exporter shows relative paths unsupported
This error is technically correct when the operators path doesn't support relative paths. The collection exporter allows relative paths and expands them before passing the value to the operator. Resolve by suppressing the warning. Ref: !137510
This commit is contained in:
@@ -2403,6 +2403,16 @@ float uiLayoutGetSearchWeight(uiLayout *layout);
|
||||
int uiLayoutListItemPaddingWidth();
|
||||
void uiLayoutListItemAddPadding(uiLayout *layout);
|
||||
|
||||
/** Support suppressing checks typically performed to communicate issues to users. */
|
||||
enum class LayoutSuppressFlag : uint8_t {
|
||||
PathSupportsBlendFileRelative = 1 << 0,
|
||||
};
|
||||
ENUM_OPERATORS(LayoutSuppressFlag, LayoutSuppressFlag::PathSupportsBlendFileRelative)
|
||||
|
||||
LayoutSuppressFlag uiLayoutSuppressFlagGet(const uiLayout *layout);
|
||||
void uiLayoutSuppressFlagSet(uiLayout *layout, LayoutSuppressFlag flag);
|
||||
void uiLayoutSuppressFlagClear(uiLayout *layout, LayoutSuppressFlag flag);
|
||||
|
||||
/* Layout create functions. */
|
||||
|
||||
uiLayout *uiLayoutRow(uiLayout *layout, bool align);
|
||||
|
||||
@@ -180,6 +180,8 @@ struct uiLayout : uiItem {
|
||||
float units[2];
|
||||
/** Is copied to uiButs created in this layout. */
|
||||
float search_weight;
|
||||
|
||||
LayoutSuppressFlag suppress_flag;
|
||||
};
|
||||
|
||||
struct uiLayoutItemFlow : uiLayout {
|
||||
@@ -1090,7 +1092,13 @@ static uiBut *ui_item_with_label(uiLayout *layout,
|
||||
if (ELEM(subtype, PROP_FILEPATH, PROP_DIRPATH)) {
|
||||
if ((RNA_property_flag(prop) & PROP_PATH_SUPPORTS_BLEND_RELATIVE) == 0) {
|
||||
if (BLI_path_is_rel(but->drawstr.c_str())) {
|
||||
UI_but_flag_enable(but, UI_BUT_REDALERT);
|
||||
|
||||
/* Finally check that this isn't suppressed, see: #137507. */
|
||||
if ((uiLayoutSuppressFlagGet(layout) &
|
||||
LayoutSuppressFlag::PathSupportsBlendFileRelative) != LayoutSuppressFlag(0))
|
||||
{
|
||||
UI_but_flag_enable(but, UI_BUT_REDALERT);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -5484,6 +5492,21 @@ void uiLayoutListItemAddPadding(uiLayout *layout)
|
||||
UI_block_layout_set_current(block, layout);
|
||||
}
|
||||
|
||||
LayoutSuppressFlag uiLayoutSuppressFlagGet(const uiLayout *layout)
|
||||
{
|
||||
return layout->suppress_flag;
|
||||
}
|
||||
|
||||
void uiLayoutSuppressFlagSet(uiLayout *layout, LayoutSuppressFlag flag)
|
||||
{
|
||||
layout->suppress_flag |= flag;
|
||||
}
|
||||
|
||||
void uiLayoutSuppressFlagClear(uiLayout *layout, LayoutSuppressFlag flag)
|
||||
{
|
||||
layout->suppress_flag &= ~flag;
|
||||
}
|
||||
|
||||
/** \} */
|
||||
|
||||
/* -------------------------------------------------------------------- */
|
||||
|
||||
@@ -1029,7 +1029,10 @@ static std::unique_ptr<uiTooltipData> ui_tooltip_data_from_button_or_extra_icon(
|
||||
}
|
||||
|
||||
/* Warn if relative paths are used when unsupported (will already display red-alert). */
|
||||
if (ELEM(but->type, UI_BTYPE_TEXT)) {
|
||||
if (ELEM(but->type, UI_BTYPE_TEXT) &&
|
||||
/* Check red-alert, if the flag is not set, then this was suppressed. */
|
||||
(but->flag & UI_BUT_REDALERT))
|
||||
{
|
||||
if (rnaprop) {
|
||||
PropertySubType subtype = RNA_property_subtype(rnaprop);
|
||||
if (ELEM(subtype, PROP_FILEPATH, PROP_DIRPATH)) {
|
||||
|
||||
@@ -369,6 +369,13 @@ static void draw_export_properties(bContext *C,
|
||||
uiLayoutSetPropDecorate(col, false);
|
||||
|
||||
PropertyRNA *prop = RNA_struct_find_property(op->ptr, "filepath");
|
||||
|
||||
/* WARNING: using relative paths for the operator file-path is not exactly correct:
|
||||
* A relative path can be set here but it is never passed to the operator.
|
||||
* The export collection reads & expands this path before passing it to the operator.
|
||||
* Suppress the check here to avoid this showing red-alert with an warning in the tip. */
|
||||
uiLayoutSuppressFlagSet(layout, LayoutSuppressFlag::PathSupportsBlendFileRelative);
|
||||
|
||||
std::string placeholder = "//" + filename;
|
||||
uiItemFullR(col,
|
||||
op->ptr,
|
||||
@@ -382,6 +389,8 @@ static void draw_export_properties(bContext *C,
|
||||
|
||||
template_operator_property_buts_draw_single(
|
||||
C, op, layout, UI_BUT_LABEL_ALIGN_NONE, UI_TEMPLATE_OP_PROPS_HIDE_PRESETS);
|
||||
|
||||
uiLayoutSuppressFlagClear(layout, LayoutSuppressFlag::PathSupportsBlendFileRelative);
|
||||
}
|
||||
|
||||
static void draw_exporter_item(uiList * /*ui_list*/,
|
||||
|
||||
Reference in New Issue
Block a user