changes to relative path option
- initialize the relative_path option in ED_fileselect_get_params(), saves initializing within every operators own init functions, some even trying to initialize a non existing property. - don't set the operator default from the user preferece, operator property defaults should be static else python scripts for eg can get different defaults depending on user settings, this also wont get updated when user-defaults are edited so generally confusing & not good practice.
This commit is contained in:
@@ -1707,10 +1707,7 @@ static int open_invoke(bContext *C, wmOperator *op, wmEvent *UNUSED(event))
|
||||
}
|
||||
|
||||
path = (font && strcmp(font->name, FO_BUILTIN_NAME) != 0)? font->name: U.fontdir;
|
||||
|
||||
if(!RNA_property_is_set(op->ptr, "relative_path"))
|
||||
RNA_boolean_set(op->ptr, "relative_path", U.flag & USER_RELPATHS);
|
||||
|
||||
|
||||
if(RNA_property_is_set(op->ptr, "filepath"))
|
||||
return open_exec(C, op);
|
||||
|
||||
|
@@ -1163,9 +1163,6 @@ static int multires_external_save_invoke(bContext *C, wmOperator *op, wmEvent *U
|
||||
if(CustomData_external_test(&me->fdata, CD_MDISPS))
|
||||
return OPERATOR_CANCELLED;
|
||||
|
||||
if(!RNA_property_is_set(op->ptr, "relative_path"))
|
||||
RNA_boolean_set(op->ptr, "relative_path", U.flag & USER_RELPATHS);
|
||||
|
||||
if(RNA_property_is_set(op->ptr, "filepath"))
|
||||
return multires_external_save_exec(C, op);
|
||||
|
||||
|
@@ -712,9 +712,6 @@ static int envmap_save_invoke(bContext *C, wmOperator *op, wmEvent *UNUSED(event
|
||||
{
|
||||
//Scene *scene= CTX_data_scene(C);
|
||||
|
||||
if(!RNA_property_is_set(op->ptr, "relative_path"))
|
||||
RNA_boolean_set(op->ptr, "relative_path", U.flag & USER_RELPATHS);
|
||||
|
||||
if(RNA_property_is_set(op->ptr, "filepath"))
|
||||
return envmap_save_exec(C, op);
|
||||
|
||||
|
@@ -164,9 +164,6 @@ static int open_exec(bContext *UNUSED(C), wmOperator *op)
|
||||
|
||||
static int open_invoke(bContext *C, wmOperator *op, wmEvent *event)
|
||||
{
|
||||
if(!RNA_property_is_set(op->ptr, "relative_path"))
|
||||
RNA_boolean_set(op->ptr, "relative_path", U.flag & USER_RELPATHS);
|
||||
|
||||
if(RNA_property_is_set(op->ptr, "filepath"))
|
||||
return open_exec(C, op);
|
||||
|
||||
@@ -264,9 +261,6 @@ static int mixdown_exec(bContext *C, wmOperator *op)
|
||||
|
||||
static int mixdown_invoke(bContext *C, wmOperator *op, wmEvent *event)
|
||||
{
|
||||
if(!RNA_property_is_set(op->ptr, "relative_path"))
|
||||
RNA_boolean_set(op->ptr, "relative_path", U.flag & USER_RELPATHS);
|
||||
|
||||
if(RNA_property_is_set(op->ptr, "filepath"))
|
||||
return mixdown_exec(C, op);
|
||||
|
||||
|
@@ -201,6 +201,8 @@ static int file_browse_invoke(bContext *C, wmOperator *op, wmEvent *event)
|
||||
RNA_string_set(op->ptr, path_prop, str);
|
||||
MEM_freeN(str);
|
||||
|
||||
/* normally ED_fileselect_get_params would handle this but we need to because of stupid
|
||||
* user-prefs exception - campbell */
|
||||
if(RNA_struct_find_property(op->ptr, "relative_path")) {
|
||||
if(!RNA_property_is_set(op->ptr, "relative_path")) {
|
||||
/* annoying exception!, if were dealign with the user prefs, default relative to be off */
|
||||
|
@@ -125,6 +125,7 @@ short ED_fileselect_set_params(SpaceFile *sfile)
|
||||
const short is_filepath= (RNA_struct_find_property(op->ptr, "filepath") != NULL);
|
||||
const short is_filename= (RNA_struct_find_property(op->ptr, "filename") != NULL);
|
||||
const short is_directory= (RNA_struct_find_property(op->ptr, "directory") != NULL);
|
||||
const short is_relative_path= (RNA_struct_find_property(op->ptr, "relative_path") != NULL);
|
||||
|
||||
BLI_strncpy(params->title, op->type->name, sizeof(params->title));
|
||||
|
||||
@@ -228,6 +229,11 @@ short ED_fileselect_set_params(SpaceFile *sfile)
|
||||
params->display= FILE_SHORTDISPLAY;
|
||||
}
|
||||
|
||||
if (is_relative_path) {
|
||||
if (!RNA_property_is_set(op->ptr, "relative_path")) {
|
||||
RNA_boolean_set(op->ptr, "relative_path", U.flag & USER_RELPATHS);
|
||||
}
|
||||
}
|
||||
}
|
||||
else {
|
||||
/* default values, if no operator */
|
||||
|
@@ -843,10 +843,6 @@ static int open_invoke(bContext *C, wmOperator *op, wmEvent *UNUSED(event))
|
||||
|
||||
if(ima)
|
||||
path= ima->name;
|
||||
|
||||
|
||||
if(!RNA_property_is_set(op->ptr, "relative_path"))
|
||||
RNA_boolean_set(op->ptr, "relative_path", U.flag & USER_RELPATHS);
|
||||
|
||||
if(RNA_property_is_set(op->ptr, "filepath"))
|
||||
return open_exec(C, op);
|
||||
@@ -1167,9 +1163,6 @@ static int save_as_invoke(bContext *C, wmOperator *op, wmEvent *UNUSED(event))
|
||||
Scene *scene= CTX_data_scene(C);
|
||||
SaveImageOptions simopts;
|
||||
|
||||
if(!RNA_property_is_set(op->ptr, "relative_path"))
|
||||
RNA_boolean_set(op->ptr, "relative_path", U.flag & USER_RELPATHS);
|
||||
|
||||
if(RNA_property_is_set(op->ptr, "filepath"))
|
||||
return save_as_exec(C, op);
|
||||
|
||||
|
@@ -380,9 +380,6 @@ static int sequencer_add_movie_strip_invoke(bContext *C, wmOperator *op, wmEvent
|
||||
|
||||
sequencer_generic_invoke_xy__internal(C, op, event, 0);
|
||||
|
||||
if(!RNA_property_is_set(op->ptr, "relative_path"))
|
||||
RNA_boolean_set(op->ptr, "relative_path", U.flag & USER_RELPATHS);
|
||||
|
||||
WM_event_add_fileselect(C, op);
|
||||
return OPERATOR_RUNNING_MODAL;
|
||||
|
||||
@@ -434,10 +431,7 @@ static int sequencer_add_sound_strip_invoke(bContext *C, wmOperator *op, wmEvent
|
||||
}
|
||||
|
||||
sequencer_generic_invoke_xy__internal(C, op, event, 0);
|
||||
|
||||
if(!RNA_property_is_set(op->ptr, "relative_path"))
|
||||
RNA_boolean_set(op->ptr, "relative_path", U.flag & USER_RELPATHS);
|
||||
|
||||
|
||||
WM_event_add_fileselect(C, op);
|
||||
return OPERATOR_RUNNING_MODAL;
|
||||
|
||||
@@ -543,9 +537,6 @@ static int sequencer_add_image_strip_invoke(bContext *C, wmOperator *op, wmEvent
|
||||
}
|
||||
|
||||
sequencer_generic_invoke_xy__internal(C, op, event, SEQPROP_ENDFRAME);
|
||||
|
||||
if(!RNA_property_is_set(op->ptr, "relative_path"))
|
||||
RNA_boolean_set(op->ptr, "relative_path", U.flag & USER_RELPATHS);
|
||||
|
||||
WM_event_add_fileselect(C, op);
|
||||
return OPERATOR_RUNNING_MODAL;
|
||||
@@ -721,10 +712,6 @@ static int sequencer_add_effect_strip_invoke(bContext *C, wmOperator *op, wmEven
|
||||
sequencer_generic_invoke_xy__internal(C, op, event, prop_flag);
|
||||
|
||||
if (is_type_set && type==SEQ_PLUGIN) {
|
||||
|
||||
if(!RNA_property_is_set(op->ptr, "relative_path"))
|
||||
RNA_boolean_set(op->ptr, "relative_path", U.flag & USER_RELPATHS);
|
||||
|
||||
/* only plugins need the file selector */
|
||||
return WM_operator_filesel(C, op, event);
|
||||
}
|
||||
|
@@ -860,7 +860,7 @@ void WM_operator_properties_filesel(wmOperatorType *ot, int filter, short type,
|
||||
RNA_def_property_flag(prop, PROP_HIDDEN);
|
||||
|
||||
if(flag & WM_FILESEL_RELPATH)
|
||||
RNA_def_boolean(ot->srna, "relative_path", (U.flag & USER_RELPATHS) ? 1:0, "Relative Path", "Select the file relative to the blend file");
|
||||
RNA_def_boolean(ot->srna, "relative_path", TRUE, "Relative Path", "Select the file relative to the blend file");
|
||||
}
|
||||
|
||||
void WM_operator_properties_select_all(wmOperatorType *ot)
|
||||
@@ -1618,9 +1618,6 @@ static void WM_OT_open_mainfile(wmOperatorType *ot)
|
||||
|
||||
static int wm_link_append_invoke(bContext *C, wmOperator *op, wmEvent *UNUSED(event))
|
||||
{
|
||||
if(!RNA_property_is_set(op->ptr, "relative_path"))
|
||||
RNA_boolean_set(op->ptr, "relative_path", U.flag & USER_RELPATHS);
|
||||
|
||||
if(RNA_property_is_set(op->ptr, "filepath")) {
|
||||
return WM_operator_call(C, op);
|
||||
}
|
||||
|
Reference in New Issue
Block a user