Fix T100797: C++ exporters do not remember the path on subsequent exports

Most/all C++ based IO code had a pattern of doing using
RNA_struct_property_is_set to check whether a default path needs to
be set. However, it returns false for properties restored from
"previous operator settings" (property restoration code sets
IDP_FLAG_GHOST flag on them, which "is set" sees and goes
"nope, not set").

The fix here is to apply similar logic as 10 years ago in the
T32855 fix (rBdb250a4): use RNA_struct_property_is_set_ex instead.

Reviewed By: Campbell Barton
Differential Revision: https://developer.blender.org/D15904
This commit is contained in:
Aras Pranckevicius
2022-09-07 11:47:29 +03:00
parent 788952705c
commit 97bd04d665
7 changed files with 17 additions and 17 deletions

View File

@@ -75,7 +75,7 @@ static int wm_alembic_export_invoke(bContext *C, wmOperator *op, const wmEvent *
RNA_boolean_set(op->ptr, "init_scene_frame_range", true);
if (!RNA_struct_property_is_set(op->ptr, "filepath")) {
if (!RNA_struct_property_is_set_ex(op->ptr, "filepath", false)) {
Main *bmain = CTX_data_main(C);
char filepath[FILE_MAX];
@@ -99,7 +99,7 @@ static int wm_alembic_export_invoke(bContext *C, wmOperator *op, const wmEvent *
static int wm_alembic_export_exec(bContext *C, wmOperator *op)
{
if (!RNA_struct_property_is_set(op->ptr, "filepath")) {
if (!RNA_struct_property_is_set_ex(op->ptr, "filepath", false)) {
BKE_report(op->reports, RPT_ERROR, "No filename given");
return OPERATOR_CANCELLED;
}
@@ -619,7 +619,7 @@ static int wm_alembic_import_invoke(bContext *C, wmOperator *op, const wmEvent *
static int wm_alembic_import_exec(bContext *C, wmOperator *op)
{
if (!RNA_struct_property_is_set(op->ptr, "filepath")) {
if (!RNA_struct_property_is_set_ex(op->ptr, "filepath", false)) {
BKE_report(op->reports, RPT_ERROR, "No filename given");
return OPERATOR_CANCELLED;
}

View File

@@ -38,7 +38,7 @@ static int wm_collada_export_invoke(bContext *C, wmOperator *op, const wmEvent *
{
Main *bmain = CTX_data_main(C);
if (!RNA_struct_property_is_set(op->ptr, "filepath")) {
if (!RNA_struct_property_is_set_ex(op->ptr, "filepath", false)) {
char filepath[FILE_MAX];
const char *blendfile_path = BKE_main_blendfile_path(bmain);
@@ -98,7 +98,7 @@ static int wm_collada_export_exec(bContext *C, wmOperator *op)
int export_count;
int sample_animations;
if (!RNA_struct_property_is_set(op->ptr, "filepath")) {
if (!RNA_struct_property_is_set_ex(op->ptr, "filepath", false)) {
BKE_report(op->reports, RPT_ERROR, "No filename given");
return OPERATOR_CANCELLED;
}
@@ -709,7 +709,7 @@ static int wm_collada_import_exec(bContext *C, wmOperator *op)
int keep_bind_info;
ImportSettings import_settings;
if (!RNA_struct_property_is_set(op->ptr, "filepath")) {
if (!RNA_struct_property_is_set_ex(op->ptr, "filepath", false)) {
BKE_report(op->reports, RPT_ERROR, "No filename given");
return OPERATOR_CANCELLED;
}

View File

@@ -74,7 +74,7 @@ static void gpencil_export_common_props_definition(wmOperatorType *ot)
static void set_export_filepath(bContext *C, wmOperator *op, const char *extension)
{
if (!RNA_struct_property_is_set(op->ptr, "filepath")) {
if (!RNA_struct_property_is_set_ex(op->ptr, "filepath", false)) {
Main *bmain = CTX_data_main(C);
char filepath[FILE_MAX];
@@ -121,7 +121,7 @@ static int wm_gpencil_export_svg_exec(bContext *C, wmOperator *op)
Scene *scene = CTX_data_scene(C);
Object *ob = CTX_data_active_object(C);
if (!RNA_struct_property_is_set(op->ptr, "filepath")) {
if (!RNA_struct_property_is_set_ex(op->ptr, "filepath", false)) {
BKE_report(op->reports, RPT_ERROR, "No filename given");
return OPERATOR_CANCELLED;
}
@@ -276,7 +276,7 @@ static int wm_gpencil_export_pdf_exec(bContext *C, wmOperator *op)
Scene *scene = CTX_data_scene(C);
Object *ob = CTX_data_active_object(C);
if (!RNA_struct_property_is_set(op->ptr, "filepath")) {
if (!RNA_struct_property_is_set_ex(op->ptr, "filepath", false)) {
BKE_report(op->reports, RPT_ERROR, "No filename given");
return OPERATOR_CANCELLED;
}

View File

@@ -65,7 +65,7 @@ static int wm_gpencil_import_svg_exec(bContext *C, wmOperator *op)
{
Scene *scene = CTX_data_scene(C);
if (!RNA_struct_property_is_set(op->ptr, "filepath") ||
if (!RNA_struct_property_is_set_ex(op->ptr, "filepath", false) ||
!(RNA_struct_find_property(op->ptr, "directory"))) {
BKE_report(op->reports, RPT_ERROR, "No filename given");
return OPERATOR_CANCELLED;

View File

@@ -58,7 +58,7 @@ static const EnumPropertyItem io_obj_path_mode[] = {
static int wm_obj_export_invoke(bContext *C, wmOperator *op, const wmEvent *UNUSED(event))
{
if (!RNA_struct_property_is_set(op->ptr, "filepath")) {
if (!RNA_struct_property_is_set_ex(op->ptr, "filepath", false)) {
Main *bmain = CTX_data_main(C);
char filepath[FILE_MAX];
@@ -79,7 +79,7 @@ static int wm_obj_export_invoke(bContext *C, wmOperator *op, const wmEvent *UNUS
static int wm_obj_export_exec(bContext *C, wmOperator *op)
{
if (!RNA_struct_property_is_set(op->ptr, "filepath")) {
if (!RNA_struct_property_is_set_ex(op->ptr, "filepath", false)) {
BKE_report(op->reports, RPT_ERROR, "No filename given");
return OPERATOR_CANCELLED;
}
@@ -410,7 +410,7 @@ static int wm_obj_import_exec(bContext *C, wmOperator *op)
OBJ_import(C, &import_params);
}
}
else if (RNA_struct_property_is_set(op->ptr, "filepath")) {
else if (RNA_struct_property_is_set_ex(op->ptr, "filepath", false)) {
/* Importing one file. */
RNA_string_get(op->ptr, "filepath", import_params.filepath);
OBJ_import(C, &import_params);

View File

@@ -53,7 +53,7 @@ static int wm_stl_import_execute(bContext *C, wmOperator *op)
STL_import(C, &params);
}
}
else if (RNA_struct_property_is_set(op->ptr, "filepath")) {
else if (RNA_struct_property_is_set_ex(op->ptr, "filepath", false)) {
RNA_string_get(op->ptr, "filepath", params.filepath);
STL_import(C, &params);
}

View File

@@ -84,7 +84,7 @@ static int wm_usd_export_invoke(bContext *C, wmOperator *op, const wmEvent *UNUS
options->as_background_job = true;
op->customdata = options;
if (!RNA_struct_property_is_set(op->ptr, "filepath")) {
if (!RNA_struct_property_is_set_ex(op->ptr, "filepath", false)) {
Main *bmain = CTX_data_main(C);
char filepath[FILE_MAX];
const char *main_blendfile_path = BKE_main_blendfile_path(bmain);
@@ -107,7 +107,7 @@ static int wm_usd_export_invoke(bContext *C, wmOperator *op, const wmEvent *UNUS
static int wm_usd_export_exec(bContext *C, wmOperator *op)
{
if (!RNA_struct_property_is_set(op->ptr, "filepath")) {
if (!RNA_struct_property_is_set_ex(op->ptr, "filepath", false)) {
BKE_report(op->reports, RPT_ERROR, "No filename given");
return OPERATOR_CANCELLED;
}
@@ -331,7 +331,7 @@ static int wm_usd_import_invoke(bContext *C, wmOperator *op, const wmEvent *even
static int wm_usd_import_exec(bContext *C, wmOperator *op)
{
if (!RNA_struct_property_is_set(op->ptr, "filepath")) {
if (!RNA_struct_property_is_set_ex(op->ptr, "filepath", false)) {
BKE_report(op->reports, RPT_ERROR, "No filename given");
return OPERATOR_CANCELLED;
}