Oldie: Texture buttons - "Add New Image" - crashes on changing X or Y resolution.

I've greyed out these buttons now, changing image memory that's in use by the
preview render is not supported.

A real fix I did was assigning the new image to the texture, that was missing.
This commit is contained in:
Ton Roosendaal 2012-10-25 16:58:52 +00:00
parent 09ed97afc5
commit ce77c5af1c
2 changed files with 12 additions and 2 deletions

@ -722,8 +722,10 @@ void uiTemplateImage(uiLayout *layout, bContext *C, PointerRNA *ptr, const char
split = uiLayoutSplit(layout, 0.0f, FALSE);
col = uiLayoutColumn(split, TRUE);
uiLayoutSetEnabled(col, 0);
uiItemR(col, &imaptr, "generated_width", 0, "X", ICON_NONE);
uiItemR(col, &imaptr, "generated_height", 0, "Y", ICON_NONE);
uiItemR(col, &imaptr, "use_generated_float", 0, NULL, ICON_NONE);
uiItemR(split, &imaptr, "generated_type", UI_ITEM_R_EXPAND, NULL, ICON_NONE);

@ -1682,16 +1682,24 @@ static int image_new_exec(bContext *C, wmOperator *op)
RNA_property_pointer_set(&ptr, prop, idptr);
RNA_property_update(C, &ptr, prop);
}
else if (sima)
else if (sima) {
ED_space_image_set(sima, scene, obedit, ima);
}
else {
Tex *tex = CTX_data_pointer_get_type(C, "texture", &RNA_Texture).data;
if (tex && tex->type == TEX_IMAGE) {
tex->ima= ima;
ED_area_tag_redraw(CTX_wm_area(C));
}
}
// XXX other users?
BKE_image_signal(ima, (sima) ? &sima->iuser : NULL, IMA_SIGNAL_USER_NEW_IMAGE);
return OPERATOR_FINISHED;
}
/* XXX, Ton is not a fan of OK buttons but using this function to avoid undo/redo bug while in mesh-editmode, - campbell */
/* XXX Note: the WM_operator_props_dialog_popup() doesn't work for uiIDContextProperty(), image is not being that way */
static int image_new_invoke(bContext *C, wmOperator *op, wmEvent *UNUSED(event))
{
return WM_operator_props_dialog_popup(C, op, 300, 100);