- use BLI_findstring rather then while loop for listbase lookups

- remove BLI_assert I recently added to RNA_property_pointer_type since its intentionally called with no type check.
This commit is contained in:
Campbell Barton 2011-10-03 12:56:33 +00:00
parent 7fec67ab40
commit 758e34b45d
2 changed files with 6 additions and 14 deletions

@ -427,11 +427,11 @@ static void image_undo_restore(bContext *C, ListBase *lb)
for(tile=lb->first; tile; tile=tile->next) { for(tile=lb->first; tile; tile=tile->next) {
/* find image based on name, pointer becomes invalid with global undo */ /* find image based on name, pointer becomes invalid with global undo */
if(ima && strcmp(tile->idname, ima->id.name)==0); if(ima && strcmp(tile->idname, ima->id.name)==0) {
/* ima is valid */
}
else { else {
for(ima=bmain->image.first; ima; ima=ima->id.next) ima= BLI_findstring(&bmain->image, tile->idname, offsetof(ID, name));
if(strcmp(tile->idname, ima->id.name)==0)
break;
} }
ibuf= BKE_image_get_ibuf(ima, NULL); ibuf= BKE_image_get_ibuf(ima, NULL);
@ -442,13 +442,7 @@ static void image_undo_restore(bContext *C, ListBase *lb)
full image user (which isn't so obvious, btw) try to find ImBuf with full image user (which isn't so obvious, btw) try to find ImBuf with
matched file name in list of already loaded images */ matched file name in list of already loaded images */
ibuf= ima->ibufs.first; ibuf= BLI_findstring(&ima->ibufs, tile->ibufname, offsetof(ImBuf, name));
while(ibuf) {
if(strcmp(tile->ibufname, ibuf->name)==0)
break;
ibuf= ibuf->next;
}
} }
if (!ima || !ibuf || !(ibuf->rect || ibuf->rect_float)) if (!ima || !ibuf || !(ibuf->rect || ibuf->rect_float))

@ -1095,9 +1095,7 @@ StructRNA *RNA_property_pointer_type(PointerRNA *ptr, PropertyRNA *prop)
if(cprop->item_type) if(cprop->item_type)
return cprop->item_type; return cprop->item_type;
} }
else { /* ignore other types, RNA_struct_find_nested calls with unchecked props */
BLI_assert(0);
}
return &RNA_UnknownType; return &RNA_UnknownType;
} }