forked from bartvdbraak/blender
Make sure bool will always have the same size in C and C++
There were an issues with data structures defined in headers and being used by both C and C++ on systems with stdbool unavailable. This happened because bool in this case will be defined as unsigned int, which is 4 bytes. But C++'s bool is only 1 byte and this lead to alignment issues. Now bool is always 1 byte, also made sure there's no situation like bool foo = BitField & BitFlag, which could give overflow issues. Use (BitField & BitFlag) != 0 instead. Fixes #35553: Compositor broken (Backdrop & Preview)
This commit is contained in:
parent
e99801dc70
commit
9e05f6571f
@ -119,11 +119,8 @@ typedef uint64_t u_int64_t;
|
||||
# ifdef __cplusplus
|
||||
typedef bool _BLI_Bool;
|
||||
# else
|
||||
/* using char here may cause nasty tricky bugs, e.g.
|
||||
* bool is_bit_flag = RNA_property_flag(prop) & PROP_ENUM_FLAG;
|
||||
* as PROP_ENUM_FLAG is farther than 8th bit, do_translate would be always false!
|
||||
*/
|
||||
# define _BLI_Bool unsigned int
|
||||
/* Make sure bool is alays defined with the same size for both C and C++ */
|
||||
# define _BLI_Bool unsigned char
|
||||
# endif
|
||||
# else
|
||||
# define _BLI_Bool _Bool
|
||||
|
@ -573,7 +573,7 @@ void BM_mesh_elem_index_validate(BMesh *bm, const char *location, const char *fu
|
||||
bool is_any_error = 0;
|
||||
|
||||
for (i = 0; i < 3; i++) {
|
||||
const bool is_dirty = (flag_types[i] & bm->elem_index_dirty);
|
||||
const bool is_dirty = (flag_types[i] & bm->elem_index_dirty) != 0;
|
||||
int index = 0;
|
||||
bool is_error = false;
|
||||
int err_val = 0;
|
||||
|
@ -399,9 +399,9 @@ float ANIM_unit_mapping_get_factor(Scene *scene, ID *id, FCurve *fcu, short rest
|
||||
static short bezt_unit_mapping_apply(KeyframeEditData *ked, BezTriple *bezt)
|
||||
{
|
||||
/* mapping factor is stored in f1, flags are stored in i1 */
|
||||
const bool only_keys = (ked->i1 & ANIM_UNITCONV_ONLYKEYS);
|
||||
const bool sel_vs = (ked->i1 & ANIM_UNITCONV_SELVERTS);
|
||||
const bool skip_knot = (ked->i1 & ANIM_UNITCONV_SKIPKNOTS);
|
||||
const bool only_keys = (ked->i1 & ANIM_UNITCONV_ONLYKEYS) != 0;
|
||||
const bool sel_vs = (ked->i1 & ANIM_UNITCONV_SELVERTS) != 0;
|
||||
const bool skip_knot = (ked->i1 & ANIM_UNITCONV_SKIPKNOTS) != 0;
|
||||
float fac = ked->f1;
|
||||
|
||||
/* adjust BezTriple handles only if allowed to */
|
||||
|
@ -3411,7 +3411,7 @@ void ui_draw_but(const bContext *C, ARegion *ar, uiStyle *style, uiBut *but, rct
|
||||
if (wt) {
|
||||
//rcti disablerect = *rect; /* rect gets clipped smaller for text */
|
||||
int roundboxalign, state;
|
||||
bool disabled = FALSE;
|
||||
bool disabled = false;
|
||||
|
||||
roundboxalign = widget_roundbox_set(but, rect);
|
||||
|
||||
@ -3420,7 +3420,7 @@ void ui_draw_but(const bContext *C, ARegion *ar, uiStyle *style, uiBut *but, rct
|
||||
|
||||
if (state & (UI_BUT_DISABLED | UI_BUT_INACTIVE))
|
||||
if (but->dt != UI_EMBOSSP)
|
||||
disabled = TRUE;
|
||||
disabled = true;
|
||||
|
||||
if (disabled)
|
||||
ui_widget_color_disabled(wt);
|
||||
|
@ -258,7 +258,7 @@ static void buttons_texture_users_from_context(ListBase *users, const bContext *
|
||||
World *wrld = NULL;
|
||||
Brush *brush = NULL;
|
||||
ID *pinid = sbuts->pinid;
|
||||
bool limited_mode = sbuts->flag & SB_TEX_USER_LIMITED;
|
||||
bool limited_mode = (sbuts->flag & SB_TEX_USER_LIMITED) != 0;
|
||||
|
||||
/* get data from context */
|
||||
if (pinid) {
|
||||
|
@ -1086,7 +1086,7 @@ static int flyApply_ndof(bContext *C, FlyInfo *fly)
|
||||
|
||||
#if 0
|
||||
bool do_rotate = (flag & NDOF_SHOULD_ROTATE) && (fly->pan_view == false);
|
||||
bool do_translate = (flag & (NDOF_SHOULD_PAN | NDOF_SHOULD_ZOOM));
|
||||
bool do_translate = (flag & (NDOF_SHOULD_PAN | NDOF_SHOULD_ZOOM)) != 0;
|
||||
#endif
|
||||
|
||||
bool do_rotate = (fly->pan_view == false);
|
||||
|
@ -132,7 +132,7 @@ int imb_savepng(struct ImBuf *ibuf, const char *name, int flags)
|
||||
int i, bytesperpixel, color_type = PNG_COLOR_TYPE_GRAY;
|
||||
FILE *fp = NULL;
|
||||
|
||||
bool is_16bit = (ibuf->ftype & PNG_16BIT);
|
||||
bool is_16bit = (ibuf->ftype & PNG_16BIT) != 0;
|
||||
bool has_float = (ibuf->rect_float != NULL);
|
||||
int channels_in_float = ibuf->channels ? ibuf->channels : 4;
|
||||
|
||||
|
@ -110,7 +110,7 @@ static DerivedMesh *applyModifier(ModifierData *md, struct Object *ob,
|
||||
MDeformVert *dvert = NULL;
|
||||
BevelModifierData *bmd = (BevelModifierData *) md;
|
||||
const float threshold = cosf((bmd->bevel_angle + 0.00001f) * (float)M_PI / 180.0f);
|
||||
const bool vertex_only = bmd->flags & BME_BEVEL_VERT;
|
||||
const bool vertex_only = (bmd->flags & BME_BEVEL_VERT) != 0;
|
||||
const bool do_clamp = !(bmd->flags & BME_BEVEL_OVERLAP_OK);
|
||||
|
||||
bm = DM_to_bmesh(dm);
|
||||
|
@ -472,7 +472,7 @@ void RE_FreePersistentData(void)
|
||||
/* disprect is optional, if NULL it assumes full window render */
|
||||
void RE_InitState(Render *re, Render *source, RenderData *rd, SceneRenderLayer *srl, int winx, int winy, rcti *disprect)
|
||||
{
|
||||
bool had_freestyle = (re->r.mode & R_EDGE_FRS);
|
||||
bool had_freestyle = (re->r.mode & R_EDGE_FRS) != 0;
|
||||
|
||||
re->ok = TRUE; /* maybe flag */
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user