diff options
Diffstat (limited to 'source')
-rw-r--r-- | source/blender/editors/interface/interface_templates.c | 2 | ||||
-rw-r--r-- | source/blender/imbuf/intern/thumbs_blend.c | 125 | ||||
-rw-r--r-- | source/blender/windowmanager/intern/wm_operators.c | 4 |
3 files changed, 77 insertions, 54 deletions
diff --git a/source/blender/editors/interface/interface_templates.c b/source/blender/editors/interface/interface_templates.c index cbe10496a72..f951def739f 100644 --- a/source/blender/editors/interface/interface_templates.c +++ b/source/blender/editors/interface/interface_templates.c @@ -197,7 +197,7 @@ static void id_search_cb(const bContext *C, void *arg_template, char *str, uiSea if (RNA_function_call(C, &reports, &ptr, func, &parms) == 0) { int* ret; - RNA_parameter_get_lookup(&parms, "ret", &ret); + RNA_parameter_get_lookup(&parms, "ret", (void **)&ret); if (!(*ret)) { RNA_parameter_list_free(&parms); diff --git a/source/blender/imbuf/intern/thumbs_blend.c b/source/blender/imbuf/intern/thumbs_blend.c index c5c853f0c93..2b55e87546a 100644 --- a/source/blender/imbuf/intern/thumbs_blend.c +++ b/source/blender/imbuf/intern/thumbs_blend.c @@ -37,54 +37,60 @@ /* extracts the thumbnail from between the 'REND' and the 'GLOB' * chunks of the header, dont use typical blend loader because its too slow */ -ImBuf *IMB_loadblend_thumb(const char *path) + +static ImBuf *loadblend_thumb(gzFile gzfile) { char buf[8]; int code= 0; char endian, pointer_size; char endian_switch; int len, im_len, x, y; - int *rect= NULL; + ImBuf *img= NULL; - gzFile gzfile; - - ImBuf *img; - - /* not necessarily a gzip */ - gzfile = gzopen(path, "rb"); - if (NULL == gzfile ) { - return NULL; - } - /* read the blend file header */ - if(gzread(gzfile, buf, 8) != 8) goto thumb_error; - if(strncmp(buf, "BLENDER", 7)) goto thumb_error; - - if(buf[7]=='-') pointer_size= 8; - else if(buf[7]=='_') pointer_size= 4; - else goto thumb_error; - + if(gzread(gzfile, buf, 8) != 8) + return NULL; + if(strncmp(buf, "BLENDER", 7)) + return NULL; + + if(buf[7]=='-') + pointer_size= 8; + else if(buf[7]=='_') + pointer_size= 4; + else + return NULL; + /* read the next 4 bytes, only need the first char, ignore the version */ /* endian and vertsion (ignored) */ - if(gzread(gzfile, buf, 4) != 4) goto thumb_error; - - if(buf[0]=='V') endian= B_ENDIAN; /* big: PPC */ - else if(buf[0]=='v') endian= L_ENDIAN; /* little: x86 */ - else goto thumb_error; + if(gzread(gzfile, buf, 4) != 4) + return NULL; + + if(buf[0]=='V') + endian= B_ENDIAN; /* big: PPC */ + else if(buf[0]=='v') + endian= L_ENDIAN; /* little: x86 */ + else + return NULL; while(gzread(gzfile, &code, sizeof(int)) == sizeof(int)) { endian_switch = ((ENDIAN_ORDER != endian)) ? 1 : 0; - - if(gzread(gzfile, buf, sizeof(int)) != sizeof(int)) goto thumb_error; + + if(gzread(gzfile, buf, sizeof(int)) != sizeof(int)) + return NULL; + len = *( (int *)((void *)buf) ); - if(endian_switch) SWITCH_INT(len); - + + if(endian_switch) + SWITCH_INT(len); + /* finally read the rest of the bhead struct, pointer and 2 ints */ - if(gzread(gzfile, buf, pointer_size) != pointer_size) goto thumb_error; - if(gzread(gzfile, buf, sizeof(int) * 2) != sizeof(int) * 2) goto thumb_error; + if(gzread(gzfile, buf, pointer_size) != pointer_size) + return NULL; + if(gzread(gzfile, buf, sizeof(int) * 2) != sizeof(int) * 2) + return NULL; + /* we dont actually care whats in the bhead */ - if (code==REND) { gzseek(gzfile, len, SEEK_CUR); /* skip to the next */ } @@ -92,40 +98,57 @@ ImBuf *IMB_loadblend_thumb(const char *path) break; } } - + /* using 'TEST' since new names segfault when loading in old blenders */ - if(code != TEST) goto thumb_error; - - if(gzread(gzfile, &x, sizeof(int)) != sizeof(int)) goto thumb_error; - if(gzread(gzfile, &y, sizeof(int)) != sizeof(int)) goto thumb_error; + if(code != TEST) + return NULL; + + if(gzread(gzfile, &x, sizeof(int)) != sizeof(int)) + return NULL; + if(gzread(gzfile, &y, sizeof(int)) != sizeof(int)) + return NULL; + len -= sizeof(int) * 2; - if(endian_switch) { SWITCH_INT(x); SWITCH_INT(y); } + if(endian_switch) { + SWITCH_INT(x); + SWITCH_INT(y); + } /* inconsistant image size, quit early */ im_len = x * y * sizeof(int); - if(im_len != len) goto thumb_error; + if(im_len != len) + return NULL; /* finally malloc and read the data */ - rect= MEM_mallocN(len, "imb_loadblend_thumb"); + img= IMB_allocImBuf(x, y, 32, IB_rect, 0); + + if(gzread(gzfile, img->rect, len) != len) { + IMB_freeImBuf(img); + img= NULL; + } - if(gzread(gzfile, rect, len) != len) goto thumb_error; + return img; +} - /* read ok! */ - gzclose(gzfile); +ImBuf *IMB_loadblend_thumb(const char *path) +{ + gzFile gzfile; - img = IMB_allocImBuf(x, y, 32, IB_rect | IB_metadata, 0); + /* not necessarily a gzip */ + gzfile = gzopen(path, "rb"); - memcpy(img->rect, rect, im_len); + if (NULL == gzfile ) { + return NULL; + } + else { + ImBuf *img= loadblend_thumb(gzfile); - MEM_freeN(rect); - - return img; + /* read ok! */ + gzclose(gzfile); -thumb_error: - gzclose(gzfile); - if(rect) MEM_freeN(rect); - return NULL; + return img; + } } /* add a fake passepartout overlay to a byte buffer, use for blend file thumbnails */ diff --git a/source/blender/windowmanager/intern/wm_operators.c b/source/blender/windowmanager/intern/wm_operators.c index 78e1c7d87a3..09c11bcfda5 100644 --- a/source/blender/windowmanager/intern/wm_operators.c +++ b/source/blender/windowmanager/intern/wm_operators.c @@ -2611,7 +2611,7 @@ static void wm_radial_control_paint(bContext *C, int x, int y, void *customdata) ViewContext vc; - int hit = 0; + // int hit = 0; int flip; int sign; @@ -2779,7 +2779,7 @@ int WM_radial_control_modal(bContext *C, wmOperator *op, wmEvent *event) int WM_radial_control_invoke(bContext *C, wmOperator *op, wmEvent *event) { wmRadialControl *rc = MEM_callocN(sizeof(wmRadialControl), "radial control"); - wmWindow *win = CTX_wm_window(C); + // wmWindow *win = CTX_wm_window(C); int mode = RNA_int_get(op->ptr, "mode"); float initial_value = RNA_float_get(op->ptr, "initial_value"); //float initial_size = RNA_float_get(op->ptr, "initial_size"); |