Cleanup: Quiet GCC maybe uninitialized warning

There was a false positive here. Thankfully, marking the button's type
as constant can quiet the warning.
This commit is contained in:
Hans Goudey 2020-08-15 22:20:40 -04:00
parent 2c61c3d733
commit 93304b483a
1 changed files with 12 additions and 10 deletions

View File

@ -2025,6 +2025,8 @@ static void ui_apply_but_TRACKPREVIEW(bContext *C, uiBut *but, uiHandleButtonDat
static void ui_apply_but(
bContext *C, uiBlock *block, uiBut *but, uiHandleButtonData *data, const bool interactive)
{
const int but_type = but->type; /* Store as const to quiet maybe uninitialized warning. */
char *editstr;
double *editval;
float *editvec;
@ -2086,36 +2088,36 @@ static void ui_apply_but(
editstr = but->editstr;
editval = but->editval;
editvec = but->editvec;
if (but->type == UI_BTYPE_COLORBAND) {
if (but_type == UI_BTYPE_COLORBAND) {
uiButColorBand *but_coba = (uiButColorBand *)but;
editcoba = but_coba->edit_coba;
}
else if (but->type == UI_BTYPE_CURVE) {
else if (but_type == UI_BTYPE_CURVE) {
uiButCurveMapping *but_cumap = (uiButCurveMapping *)but;
editcumap = but_cumap->edit_cumap;
}
else if (but->type == UI_BTYPE_CURVEPROFILE) {
else if (but_type == UI_BTYPE_CURVEPROFILE) {
uiButCurveProfile *but_profile = (uiButCurveProfile *)but;
editprofile = but_profile->edit_profile;
}
but->editstr = NULL;
but->editval = NULL;
but->editvec = NULL;
if (but->type == UI_BTYPE_COLORBAND) {
if (but_type == UI_BTYPE_COLORBAND) {
uiButColorBand *but_coba = (uiButColorBand *)but;
but_coba->edit_coba = NULL;
}
else if (but->type == UI_BTYPE_CURVE) {
else if (but_type == UI_BTYPE_CURVE) {
uiButCurveMapping *but_cumap = (uiButCurveMapping *)but;
but_cumap->edit_cumap = NULL;
}
else if (but->type == UI_BTYPE_CURVEPROFILE) {
else if (but_type == UI_BTYPE_CURVEPROFILE) {
uiButCurveProfile *but_profile = (uiButCurveProfile *)but;
but_profile->edit_profile = NULL;
}
/* handle different types */
switch (but->type) {
switch (but_type) {
case UI_BTYPE_BUT:
case UI_BTYPE_DECORATOR:
ui_apply_but_BUT(C, but, data);
@ -2221,15 +2223,15 @@ static void ui_apply_but(
but->editstr = editstr;
but->editval = editval;
but->editvec = editvec;
if (but->type == UI_BTYPE_COLORBAND) {
if (but_type == UI_BTYPE_COLORBAND) {
uiButColorBand *but_coba = (uiButColorBand *)but;
but_coba->edit_coba = editcoba;
}
else if (but->type == UI_BTYPE_CURVE) {
else if (but_type == UI_BTYPE_CURVE) {
uiButCurveMapping *but_cumap = (uiButCurveMapping *)but;
but_cumap->edit_cumap = editcumap;
}
else if (but->type == UI_BTYPE_CURVEPROFILE) {
else if (but_type == UI_BTYPE_CURVEPROFILE) {
uiButCurveProfile *but_profile = (uiButCurveProfile *)but;
but_profile->edit_profile = editprofile;
}