- 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.
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);
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;
gzfile= gzopen(name, "rb");
- if (NULL == gzfile) {
+ if (gzfile == Z_NULL) {
BKE_report(reports, RPT_ERROR, "Unable to open");
return NULL;
} else {
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;
}
#include <stddef.h>
#include <string.h>
#include <stdlib.h>
+#include <errno.h>
#include "MEM_guardedalloc.h"
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;
}
#include <stdlib.h>
#include <math.h>
#include <string.h>
+#include <errno.h>
#include "MEM_guardedalloc.h"
{
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)
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;
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)) {
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);
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++;
#include <stdlib.h>
#include <stdio.h>
+#include <errno.h>
#include "RNA_define.h"
#include "RNA_access.h"
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)
{
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)
{
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;
}
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);
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);
}
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;
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);
{
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);
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);
{
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);
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);
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);
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);
{
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);
{
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);
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);
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) {
{
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);
* 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 );
}
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.
*/
#include <stdio.h>
#include <string.h>
+#include <errno.h>
#ifdef WIN32
#include <windows.h> /* need to include windows.h so _WIN32_IE is defined */
{
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) */
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");
}
}