Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/source
diff options
context:
space:
mode:
authorCampbell Barton <ideasman42@gmail.com>2010-07-03 21:47:06 +0400
committerCampbell Barton <ideasman42@gmail.com>2010-07-03 21:47:06 +0400
commit80f6102629b746ea520d3ec54aaa6414c669a998 (patch)
tree8d254cc92120eca8be6ef5b92af7be3c3626f202 /source
parent9a85435e96af9933b282594b6ad8b23ca598d8bc (diff)
better reporting for file i/o failier, use system error message in more places: Permission Denied, No space left, File not found etc.
- blend load/save uses os message. - image load gives os message. (remove check for slash at end of line, just let the os report an error) - python api load image/font/text raise errors with message (was just retuning None for image and font) - minor edits to py api errors.
Diffstat (limited to 'source')
-rw-r--r--source/blender/blenkernel/intern/image.c7
-rw-r--r--source/blender/blenkernel/intern/object.c6
-rw-r--r--source/blender/blenloader/intern/readfile.c2
-rw-r--r--source/blender/blenloader/intern/writefile.c2
-rw-r--r--source/blender/editors/space_image/image_ops.c5
-rw-r--r--source/blender/editors/space_node/node_edit.c20
-rw-r--r--source/blender/editors/space_sequencer/sequencer_edit.c22
-rw-r--r--source/blender/makesrna/intern/rna_main_api.c41
-rw-r--r--source/blender/python/generic/bgl.c10
-rw-r--r--source/blender/python/generic/blf_api.c24
-rw-r--r--source/blender/python/generic/bpy_internal_import.c9
-rw-r--r--source/blender/windowmanager/intern/wm_files.c6
12 files changed, 93 insertions, 61 deletions
diff --git a/source/blender/blenkernel/intern/image.c b/source/blender/blenkernel/intern/image.c
index a584e91fc0f..4daa38001bf 100644
--- a/source/blender/blenkernel/intern/image.c
+++ b/source/blender/blenkernel/intern/image.c
@@ -328,13 +328,6 @@ Image *BKE_add_image_file(const char *name, int frame)
const char *libname;
char str[FILE_MAX], strtest[FILE_MAX];
- /* escape when name is directory */
- len= strlen(name);
- if(len) {
- if(name[len-1]=='/' || name[len-1]=='\\')
- return NULL;
- }
-
BLI_strncpy(str, name, sizeof(str));
BLI_path_abs(str, G.sce);
diff --git a/source/blender/blenkernel/intern/object.c b/source/blender/blenkernel/intern/object.c
index 5d3527d5afc..8d38f5c8d15 100644
--- a/source/blender/blenkernel/intern/object.c
+++ b/source/blender/blenkernel/intern/object.c
@@ -1724,10 +1724,8 @@ void object_to_mat4(Object *ob, float mat[][4])
object_to_mat3(ob, tmat);
copy_m4_m3(mat, tmat);
-
- mat[3][0]= ob->loc[0] + ob->dloc[0];
- mat[3][1]= ob->loc[1] + ob->dloc[1];
- mat[3][2]= ob->loc[2] + ob->dloc[2];
+
+ add_v3_v3v3(mat[3], ob->loc, ob->dloc);
}
int enable_cu_speed= 1;
diff --git a/source/blender/blenloader/intern/readfile.c b/source/blender/blenloader/intern/readfile.c
index e670d78ff77..50a56c74cf5 100644
--- a/source/blender/blenloader/intern/readfile.c
+++ b/source/blender/blenloader/intern/readfile.c
@@ -962,7 +962,7 @@ FileData *blo_openblenderfile(char *name, ReportList *reports)
gzfile= gzopen(name, "rb");
- if (NULL == gzfile) {
+ if (gzfile == Z_NULL) {
BKE_report(reports, RPT_ERROR, "Unable to open");
return NULL;
} else {
diff --git a/source/blender/blenloader/intern/writefile.c b/source/blender/blenloader/intern/writefile.c
index 35fda1d8aa7..497c2d37c50 100644
--- a/source/blender/blenloader/intern/writefile.c
+++ b/source/blender/blenloader/intern/writefile.c
@@ -2481,7 +2481,7 @@ int BLO_write_file(Main *mainvar, char *dir, int write_flags, ReportList *report
file = open(tempname,O_BINARY+O_WRONLY+O_CREAT+O_TRUNC, 0666);
if(file == -1) {
- BKE_report(reports, RPT_ERROR, "Unable to open file for writing.");
+ BKE_reportf(reports, RPT_ERROR, "Can't open file for writing: %s.", strerror(errno));
return 0;
}
diff --git a/source/blender/editors/space_image/image_ops.c b/source/blender/editors/space_image/image_ops.c
index 48f9e7e458e..3e269634b27 100644
--- a/source/blender/editors/space_image/image_ops.c
+++ b/source/blender/editors/space_image/image_ops.c
@@ -28,6 +28,7 @@
#include <stddef.h>
#include <string.h>
#include <stdlib.h>
+#include <errno.h>
#include "MEM_guardedalloc.h"
@@ -688,10 +689,14 @@ static int open_exec(bContext *C, wmOperator *op)
RNA_string_get(op->ptr, "filepath", str);
/* default to frame 1 if there's no scene in context */
+
+ errno= 0;
+
ima= BKE_add_image_file(str, scene ? scene->r.cfra : 1);
if(!ima) {
if(op->customdata) MEM_freeN(op->customdata);
+ BKE_reportf(op->reports, RPT_ERROR, "Can't read: \"%s\", %s.", str, errno ? strerror(errno) : "Unsupported image format");
return OPERATOR_CANCELLED;
}
diff --git a/source/blender/editors/space_node/node_edit.c b/source/blender/editors/space_node/node_edit.c
index b5ed2f4d8a7..222504179cb 100644
--- a/source/blender/editors/space_node/node_edit.c
+++ b/source/blender/editors/space_node/node_edit.c
@@ -31,6 +31,7 @@
#include <stdlib.h>
#include <math.h>
#include <string.h>
+#include <errno.h>
#include "MEM_guardedalloc.h"
@@ -2248,21 +2249,28 @@ static int node_add_file_exec(bContext *C, wmOperator *op)
{
char path[FILE_MAX];
RNA_string_get(op->ptr, "filepath", path);
+
+ errno= 0;
+
ima= BKE_add_image_file(path, scene ? scene->r.cfra : 1);
+
+ if(!ima) {
+ BKE_reportf(op->reports, RPT_ERROR, "Can't read: \"%s\", %s.", path, errno ? strerror(errno) : "Unsupported image format");
+ return OPERATOR_CANCELLED;
+ }
}
else if(RNA_property_is_set(op->ptr, "name"))
{
char name[32];
RNA_string_get(op->ptr, "name", name);
ima= (Image *)find_id("IM", name);
+
+ if(!ima) {
+ BKE_reportf(op->reports, RPT_ERROR, "Image named \"%s\", not found.", name);
+ return OPERATOR_CANCELLED;
+ }
}
- if(!ima) {
- BKE_report(op->reports, RPT_ERROR, "Not an Image.");
- return OPERATOR_CANCELLED;
- }
-
-
node_deselectall(snode);
if (snode->nodetree->type==NTREE_COMPOSIT)
diff --git a/source/blender/editors/space_sequencer/sequencer_edit.c b/source/blender/editors/space_sequencer/sequencer_edit.c
index 6d225647a52..b994b0877d7 100644
--- a/source/blender/editors/space_sequencer/sequencer_edit.c
+++ b/source/blender/editors/space_sequencer/sequencer_edit.c
@@ -761,7 +761,8 @@ static void recurs_del_seq_flag(Scene *scene, ListBase *lb, short flag, short de
BLI_remlink(lb, seq);
if(seq==last_seq) seq_active_set(scene, NULL);
if(seq->type==SEQ_META) recurs_del_seq_flag(scene, &seq->seqbase, flag, 1);
- if(seq->ipo) seq->ipo->id.us--;
+ /* if(seq->ipo) seq->ipo->id.us--; */
+ /* XXX, remove fcurve */
seq_free_sequence(scene, seq);
}
seq= seqn;
@@ -1700,10 +1701,7 @@ static int sequencer_separate_images_exec(bContext *C, wmOperator *op)
int start_ofs, cfra, frame_end;
int step= RNA_int_get(op->ptr, "length");
- if(ed==NULL)
- return OPERATOR_CANCELLED;
-
- seq= ed->seqbasep->first;
+ seq= ed->seqbasep->first; /* poll checks this is valid */
while (seq) {
if((seq->flag & SELECT) && (seq->type == SEQ_IMAGE) && (seq->len > 1)) {
@@ -1711,7 +1709,8 @@ static int sequencer_separate_images_exec(bContext *C, wmOperator *op)
see seq_free_sequence below for the real free'ing */
seq_next = seq->next;
BLI_remlink(ed->seqbasep, seq);
- if(seq->ipo) seq->ipo->id.us--;
+ /* if(seq->ipo) seq->ipo->id.us--; */
+ /* XXX, remove fcurve and assign to split image strips */
start_ofs = cfra = seq_tx_get_final_left(seq, 0);
frame_end = seq_tx_get_final_right(seq, 0);
@@ -1735,11 +1734,16 @@ static int sequencer_separate_images_exec(bContext *C, wmOperator *op)
strip_new->stripdata= se_new= MEM_callocN(sizeof(StripElem)*1, "stripelem");
strncpy(se_new->name, se->name, FILE_MAXFILE-1);
calc_sequence(scene, seq_new);
- seq_new->flag &= ~SEQ_OVERLAP;
- if (seq_test_overlap(ed->seqbasep, seq_new)) {
- shuffle_seq(ed->seqbasep, seq_new, scene);
+
+ if(step > 1) {
+ seq_new->flag &= ~SEQ_OVERLAP;
+ if (seq_test_overlap(ed->seqbasep, seq_new)) {
+ shuffle_seq(ed->seqbasep, seq_new, scene);
+ }
}
+ /* XXX, COPY FCURVES */
+ strncpy(seq_new->name+2, seq->name+2, sizeof(seq->name)-2);
seqbase_unique_name_recursive(&scene->ed->seqbase, seq_new);
cfra++;
diff --git a/source/blender/makesrna/intern/rna_main_api.c b/source/blender/makesrna/intern/rna_main_api.c
index 4564ecd586b..6c74ff2fefa 100644
--- a/source/blender/makesrna/intern/rna_main_api.c
+++ b/source/blender/makesrna/intern/rna_main_api.c
@@ -28,6 +28,7 @@
#include <stdlib.h>
#include <stdio.h>
+#include <errno.h>
#include "RNA_define.h"
#include "RNA_access.h"
@@ -260,9 +261,17 @@ Image *rna_Main_images_new(Main *bmain, char* name, int width, int height, int a
image->id.us--;
return image;
}
-Image *rna_Main_images_load(Main *bmain, char *filepath)
+Image *rna_Main_images_load(Main *bmain, ReportList *reports, char *filepath)
{
- return BKE_add_image_file(filepath, 0);
+ Image *ima;
+
+ errno= 0;
+ ima= BKE_add_image_file(filepath, 0);
+
+ if(!ima)
+ BKE_reportf(reports, RPT_ERROR, "Can't read: \"%s\", %s.", filepath, errno ? strerror(errno) : "Unsupported image format");
+
+ return ima;
}
void rna_Main_images_remove(Main *bmain, ReportList *reports, Image *image)
{
@@ -316,9 +325,18 @@ void rna_Main_metaballs_remove(Main *bmain, ReportList *reports, struct MetaBall
BKE_reportf(reports, RPT_ERROR, "MetaBall \"%s\" must have zero users to be removed, found %d.", mb->id.name+2, ID_REAL_USERS(mb));
}
-VFont *rna_Main_fonts_load(Main *bmain, char *filepath)
+VFont *rna_Main_fonts_load(Main *bmain, ReportList *reports, char *filepath)
{
- return load_vfont(filepath);
+ VFont *font;
+
+ errno= 0;
+ font= load_vfont(filepath);
+
+ if(!font)
+ BKE_reportf(reports, RPT_ERROR, "Can't read: \"%s\", %s.", filepath, errno ? strerror(errno) : "Unsupported font format");
+
+ return font;
+
}
void rna_Main_fonts_remove(Main *bmain, ReportList *reports, VFont *vfont)
{
@@ -394,11 +412,16 @@ void rna_Main_texts_remove(Main *bmain, ReportList *reports, Text *text)
free_libblock(&bmain->text, text);
/* XXX python now has invalid pointer? */
}
-Text *rna_Main_texts_load(Main *bmain, ReportList *reports, char* path)
+
+Text *rna_Main_texts_load(Main *bmain, ReportList *reports, char* filepath)
{
- Text *txt= add_text(path, bmain->name);
- if(txt==NULL)
- BKE_reportf(reports, RPT_ERROR, "Couldn't load text from path \"%s\".", path);
+ Text *txt;
+
+ errno= 0;
+ txt= add_text(filepath, bmain->name);
+
+ if(!txt)
+ BKE_reportf(reports, RPT_ERROR, "Can't read: \"%s\", %s.", filepath, errno ? strerror(errno) : "Unable to load text");
return txt;
}
@@ -692,6 +715,7 @@ void RNA_def_main_images(BlenderRNA *brna, PropertyRNA *cprop)
RNA_def_function_return(func, parm);
func= RNA_def_function(srna, "load", "rna_Main_images_load");
+ RNA_def_function_flag(func, FUNC_USE_REPORTS);
RNA_def_function_ui_description(func, "Load a new image into the main database");
parm= RNA_def_string(func, "filepath", "File Path", 0, "", "path of the file to load.");
RNA_def_property_flag(parm, PROP_REQUIRED);
@@ -791,6 +815,7 @@ void RNA_def_main_fonts(BlenderRNA *brna, PropertyRNA *cprop)
RNA_def_struct_ui_text(srna, "Main Fonts", "Collection of fonts");
func= RNA_def_function(srna, "load", "rna_Main_fonts_load");
+ RNA_def_function_flag(func, FUNC_USE_REPORTS);
RNA_def_function_ui_description(func, "Load a new font into the main database");
parm= RNA_def_string(func, "filepath", "File Path", 0, "", "path of the font to load.");
RNA_def_property_flag(parm, PROP_REQUIRED);
diff --git a/source/blender/python/generic/bgl.c b/source/blender/python/generic/bgl.c
index 806b5a5b3ce..ae19db28011 100644
--- a/source/blender/python/generic/bgl.c
+++ b/source/blender/python/generic/bgl.c
@@ -322,20 +322,20 @@ static int Buffer_ass_item(PyObject *self, int i, PyObject *v)
}
if (buf->type==GL_BYTE) {
- if (!PyArg_Parse(v, "b;Coordinates must be ints", &buf->buf.asbyte[i]))
+ if (!PyArg_Parse(v, "b:Coordinates must be ints", &buf->buf.asbyte[i]))
return -1;
} else if (buf->type==GL_SHORT) {
- if (!PyArg_Parse(v, "h;Coordinates must be ints", &buf->buf.asshort[i]))
+ if (!PyArg_Parse(v, "h:Coordinates must be ints", &buf->buf.asshort[i]))
return -1;
} else if (buf->type==GL_INT) {
- if (!PyArg_Parse(v, "i;Coordinates must be ints", &buf->buf.asint[i]))
+ if (!PyArg_Parse(v, "i:Coordinates must be ints", &buf->buf.asint[i]))
return -1;
} else if (buf->type==GL_FLOAT) {
- if (!PyArg_Parse(v, "f;Coordinates must be floats", &buf->buf.asfloat[i]))
+ if (!PyArg_Parse(v, "f:Coordinates must be floats", &buf->buf.asfloat[i]))
return -1;
} else if (buf->type==GL_DOUBLE) {
- if (!PyArg_Parse(v, "d;Coordinates must be floats", &buf->buf.asdouble[i]))
+ if (!PyArg_Parse(v, "d:Coordinates must be floats", &buf->buf.asdouble[i]))
return -1;
}
return 0;
diff --git a/source/blender/python/generic/blf_api.c b/source/blender/python/generic/blf_api.c
index 67f07ad8378..db3ce06554e 100644
--- a/source/blender/python/generic/blf_api.c
+++ b/source/blender/python/generic/blf_api.c
@@ -46,7 +46,7 @@ static PyObject *py_blf_position(PyObject *self, PyObject *args)
int fontid;
float x, y, z;
- if (!PyArg_ParseTuple(args, "ifff:BLF.position", &fontid, &x, &y, &z))
+ if (!PyArg_ParseTuple(args, "ifff:blf.position", &fontid, &x, &y, &z))
return NULL;
BLF_position(fontid, x, y, z);
@@ -71,7 +71,7 @@ static PyObject *py_blf_size(PyObject *self, PyObject *args)
{
int fontid, size, dpi;
- if (!PyArg_ParseTuple(args, "iii:BLF.size", &fontid, &size, &dpi))
+ if (!PyArg_ParseTuple(args, "iii:blf.size", &fontid, &size, &dpi))
return NULL;
BLF_size(fontid, size, dpi);
@@ -95,7 +95,7 @@ static PyObject *py_blf_aspect(PyObject *self, PyObject *args)
float aspect;
int fontid;
- if (!PyArg_ParseTuple(args, "if:BLF.aspect", &fontid, &aspect))
+ if (!PyArg_ParseTuple(args, "if:blf.aspect", &fontid, &aspect))
return NULL;
BLF_aspect(fontid, aspect);
@@ -118,7 +118,7 @@ static PyObject *py_blf_blur(PyObject *self, PyObject *args)
{
int blur, fontid;
- if (!PyArg_ParseTuple(args, "ii:BLF.blur", &fontid, &blur))
+ if (!PyArg_ParseTuple(args, "ii:blf.blur", &fontid, &blur))
return NULL;
BLF_blur(fontid, blur);
@@ -142,7 +142,7 @@ static PyObject *py_blf_draw(PyObject *self, PyObject *args)
char *text;
int fontid;
- if (!PyArg_ParseTuple(args, "is:BLF.draw", &fontid, &text))
+ if (!PyArg_ParseTuple(args, "is:blf.draw", &fontid, &text))
return NULL;
BLF_draw(fontid, text);
@@ -169,7 +169,7 @@ static PyObject *py_blf_dimensions(PyObject *self, PyObject *args)
PyObject *ret;
int fontid;
- if (!PyArg_ParseTuple(args, "is:BLF.dimensions", &fontid, &text))
+ if (!PyArg_ParseTuple(args, "is:blf.dimensions", &fontid, &text))
return NULL;
BLF_width_and_height(fontid, text, &r_width, &r_height);
@@ -201,7 +201,7 @@ static PyObject *py_blf_clipping(PyObject *self, PyObject *args)
float xmin, ymin, xmax, ymax;
int fontid;
- if (!PyArg_ParseTuple(args, "iffff:BLF.clipping", &fontid, &xmin, &ymin, &xmax, &ymax))
+ if (!PyArg_ParseTuple(args, "iffff:blf.clipping", &fontid, &xmin, &ymin, &xmax, &ymax))
return NULL;
BLF_clipping(fontid, xmin, ymin, xmax, ymax);
@@ -223,7 +223,7 @@ static PyObject *py_blf_disable(PyObject *self, PyObject *args)
{
int option, fontid;
- if (!PyArg_ParseTuple(args, "ii:BLF.disable", &fontid, &option))
+ if (!PyArg_ParseTuple(args, "ii:blf.disable", &fontid, &option))
return NULL;
BLF_disable(fontid, option);
@@ -245,7 +245,7 @@ static PyObject *py_blf_enable(PyObject *self, PyObject *args)
{
int option, fontid;
- if (!PyArg_ParseTuple(args, "ii:BLF.enable", &fontid, &option))
+ if (!PyArg_ParseTuple(args, "ii:blf.enable", &fontid, &option))
return NULL;
BLF_enable(fontid, option);
@@ -268,7 +268,7 @@ static PyObject *py_blf_rotation(PyObject *self, PyObject *args)
float angle;
int fontid;
- if (!PyArg_ParseTuple(args, "if:BLF.rotation", &fontid, &angle))
+ if (!PyArg_ParseTuple(args, "if:blf.rotation", &fontid, &angle))
return NULL;
BLF_rotation(fontid, angle);
@@ -299,7 +299,7 @@ static PyObject *py_blf_shadow(PyObject *self, PyObject *args)
int level, fontid;
float r, g, b, a;
- if (!PyArg_ParseTuple(args, "iiffff:BLF.shadow", &fontid, &level, &r, &g, &b, &a))
+ if (!PyArg_ParseTuple(args, "iiffff:blf.shadow", &fontid, &level, &r, &g, &b, &a))
return NULL;
if (level != 0 && level != 3 && level != 5) {
@@ -328,7 +328,7 @@ static PyObject *py_blf_shadow_offset(PyObject *self, PyObject *args)
{
int x, y, fontid;
- if (!PyArg_ParseTuple(args, "iii:BLF.shadow_offset", &fontid, &x, &y))
+ if (!PyArg_ParseTuple(args, "iii:blf.shadow_offset", &fontid, &x, &y))
return NULL;
BLF_shadow_offset(fontid, x, y);
diff --git a/source/blender/python/generic/bpy_internal_import.c b/source/blender/python/generic/bpy_internal_import.c
index 01d0f56bf1b..0b5129b79fa 100644
--- a/source/blender/python/generic/bpy_internal_import.c
+++ b/source/blender/python/generic/bpy_internal_import.c
@@ -237,16 +237,11 @@ static PyObject *blender_import( PyObject * self, PyObject * args, PyObject * k
* our reload() module, to handle reloading in-memory scripts
*/
-static PyObject *blender_reload( PyObject * self, PyObject * args )
+static PyObject *blender_reload( PyObject * self, PyObject * module )
{
PyObject *exception, *err, *tb;
- PyObject *module = NULL;
PyObject *newmodule = NULL;
int found= 0;
-
- /* check for a module arg */
- if( !PyArg_ParseTuple( args, "O:bpy_reload_meth", &module ) )
- return NULL;
/* try reimporting from file */
newmodule = PyImport_ReloadModule( module );
@@ -280,7 +275,7 @@ static PyObject *blender_reload( PyObject * self, PyObject * args )
}
PyMethodDef bpy_import_meth[] = { {"bpy_import_meth", (PyCFunction)blender_import, METH_VARARGS | METH_KEYWORDS, "blenders import"} };
-PyMethodDef bpy_reload_meth[] = { {"bpy_reload_meth", (PyCFunction)blender_reload, METH_VARARGS, "blenders reload"} };
+PyMethodDef bpy_reload_meth[] = { {"bpy_reload_meth", (PyCFunction)blender_reload, METH_O, "blenders reload"} };
/* Clear user modules.
diff --git a/source/blender/windowmanager/intern/wm_files.c b/source/blender/windowmanager/intern/wm_files.c
index be6ef77526e..5298711ef52 100644
--- a/source/blender/windowmanager/intern/wm_files.c
+++ b/source/blender/windowmanager/intern/wm_files.c
@@ -30,6 +30,7 @@
*/
#include <stdio.h>
#include <string.h>
+#include <errno.h>
#ifdef WIN32
#include <windows.h> /* need to include windows.h so _WIN32_IE is defined */
@@ -261,6 +262,9 @@ void WM_read_file(bContext *C, char *name, ReportList *reports)
{
int retval;
+ /* so we can get the error message */
+ errno = 0;
+
/* first try to append data from exotic file formats... */
/* it throws error box when file doesnt exist and returns -1 */
/* note; it should set some error message somewhere... (ton) */
@@ -317,7 +321,7 @@ void WM_read_file(bContext *C, char *name, ReportList *reports)
BKE_write_undo(C, "Import file");
else if(retval == -1) {
if(reports)
- BKE_reportf(reports, RPT_ERROR, "Can't read file \"%s\".", name);
+ BKE_reportf(reports, RPT_ERROR, "Can't read file: \"%s\", %s.", name, errno ? strerror(errno) : "Incompatible file format");
}
}