file-selector: when converting operator arguments to the file selector, wasnt making paths absolute (abs paths are made relative when converting the other way).

This commit is contained in:
Campbell Barton 2011-08-26 01:32:07 +00:00
parent 291ae8822d
commit 566da26173
3 changed files with 21 additions and 20 deletions

@ -657,24 +657,26 @@ void file_sfile_to_operator(wmOperator *op, SpaceFile *sfile, char *filepath)
void file_operator_to_sfile(SpaceFile *sfile, wmOperator *op) void file_operator_to_sfile(SpaceFile *sfile, wmOperator *op)
{ {
int change= FALSE; PropertyRNA *prop;
if(RNA_struct_find_property(op->ptr, "filename")) {
RNA_string_get(op->ptr, "filename", sfile->params->file);
change= TRUE;
}
if(RNA_struct_find_property(op->ptr, "directory")) {
RNA_string_get(op->ptr, "directory", sfile->params->dir);
change= TRUE;
}
/* If neither of the above are set, split the filepath back */ /* If neither of the above are set, split the filepath back */
if(RNA_struct_find_property(op->ptr, "filepath")) { if((prop= RNA_struct_find_property(op->ptr, "filepath"))) {
if(change==FALSE) {
char filepath[FILE_MAX]; char filepath[FILE_MAX];
RNA_string_get(op->ptr, "filepath", filepath); RNA_property_string_get(op->ptr, prop, filepath);
BLI_split_dirfile(filepath, sfile->params->dir, sfile->params->file); BLI_split_dirfile(filepath, sfile->params->dir, sfile->params->file);
} }
else {
if((prop= RNA_struct_find_property(op->ptr, "filename"))) {
RNA_property_string_get(op->ptr, prop, sfile->params->file);
} }
if((prop= RNA_struct_find_property(op->ptr, "directory"))) {
RNA_property_string_get(op->ptr, prop, sfile->params->dir);
}
}
/* we could check for relative_path property which is used when converting
* in the other direction but doesnt hurt to do this every time */
BLI_path_abs(sfile->params->dir, G.main->name);
/* XXX, files and dirs updates missing, not really so important though */ /* XXX, files and dirs updates missing, not really so important though */
} }

@ -983,7 +983,7 @@ static int save_image_options_init(SaveImageOptions *simopts, SpaceImage *sima,
/* unlikely but just incase */ /* unlikely but just incase */
if (ELEM3(simopts->planes, R_PLANESBW, R_PLANES24, R_PLANES32) == 0) { if (ELEM3(simopts->planes, R_PLANESBW, R_PLANES24, R_PLANES32) == 0) {
simopts->planes= 32; simopts->planes= R_PLANES32;
} }
/* some formats dont use quality so fallback to scenes quality */ /* some formats dont use quality so fallback to scenes quality */
@ -1000,7 +1000,6 @@ static int save_image_options_init(SaveImageOptions *simopts, SpaceImage *sima,
} }
BLI_path_abs(simopts->filepath, G.main->name); BLI_path_abs(simopts->filepath, G.main->name);
} }
/* cleanup */ /* cleanup */
BKE_image_release_renderresult(scene, ima); BKE_image_release_renderresult(scene, ima);
} }
@ -1026,6 +1025,7 @@ static void save_image_options_to_op(SaveImageOptions *simopts, wmOperator *op)
RNA_enum_set(op->ptr, "file_format", simopts->imtype); RNA_enum_set(op->ptr, "file_format", simopts->imtype);
// RNA_enum_set(op->ptr, "subimtype", simopts->subimtype); // RNA_enum_set(op->ptr, "subimtype", simopts->subimtype);
RNA_int_set(op->ptr, "file_quality", simopts->quality); RNA_int_set(op->ptr, "file_quality", simopts->quality);
RNA_string_set(op->ptr, "filepath", simopts->filepath); RNA_string_set(op->ptr, "filepath", simopts->filepath);
} }
@ -1050,10 +1050,10 @@ static void save_image_doit(bContext *C, SpaceImage *sima, wmOperator *op, SaveI
if(ima->type == IMA_TYPE_R_RESULT) { if(ima->type == IMA_TYPE_R_RESULT) {
/* enforce user setting for RGB or RGBA, but skip BW */ /* enforce user setting for RGB or RGBA, but skip BW */
if(simopts->planes==32) { if(simopts->planes==R_PLANES32) {
ibuf->depth= 32; ibuf->depth= 32;
} }
else if(simopts->planes==24) { else if(simopts->planes==R_PLANES24) {
ibuf->depth= 24; ibuf->depth= 24;
} }
} }

@ -117,7 +117,6 @@ static PyObject *pyop_poll(PyObject *UNUSED(self), PyObject *args)
} }
context_dict_back= CTX_py_dict_get(C); context_dict_back= CTX_py_dict_get(C);
CTX_py_dict_set(C, (void *)context_dict); CTX_py_dict_set(C, (void *)context_dict);
Py_XINCREF(context_dict); /* so we done loose it */ Py_XINCREF(context_dict); /* so we done loose it */