Cleanup: Add explicit defaults to MEM_new-allocated structs with no constructors.

While not strictly needed (currently!), relying on C++ 'default
initialization' is fragile and unreliable.
This commit is contained in:
Bastien Montagne
2025-02-14 16:40:46 +01:00
parent 2cc6f7bbb5
commit 7000c392ff
7 changed files with 71 additions and 71 deletions

View File

@@ -48,18 +48,18 @@ enum class SampleResult {
};
struct BoneDropper {
PointerRNA ptr;
PropertyRNA *prop;
PointerRNA search_ptr;
PropertyRNA *search_prop;
PointerRNA ptr = {};
PropertyRNA *prop = nullptr;
PointerRNA search_ptr = {};
PropertyRNA *search_prop = nullptr;
bool is_undo;
bool is_undo = false;
ScrArea *cursor_area; /* Area under the cursor. */
ARegionType *area_region_type;
void *draw_handle_pixel;
int name_pos[2];
char name[64];
ScrArea *cursor_area = nullptr; /* Area under the cursor. */
ARegionType *area_region_type = nullptr;
void *draw_handle_pixel = nullptr;
int name_pos[2] = {};
char name[64] = {};
};
struct BoneSampleData {

View File

@@ -60,28 +60,28 @@
#include "eyedropper_intern.hh"
struct Eyedropper {
ColorManagedDisplay *display;
ColorManagedDisplay *display = nullptr;
PointerRNA ptr;
PropertyRNA *prop;
int index;
bool is_undo;
PointerRNA ptr = {};
PropertyRNA *prop = nullptr;
int index = 0;
bool is_undo = false;
bool is_set;
float init_col[3]; /* for resetting on cancel */
bool is_set = false;
float init_col[3] = {}; /* for resetting on cancel */
bool accum_start; /* has mouse been pressed */
float accum_col[3];
int accum_tot;
bool accum_start = false; /* has mouse been pressed */
float accum_col[3] = {};
int accum_tot = 0;
wmWindow *cb_win;
int cb_win_event_xy[2];
void *draw_handle_sample_text;
char sample_text[MAX_NAME];
wmWindow *cb_win = nullptr;
int cb_win_event_xy[2] = {};
void *draw_handle_sample_text = nullptr;
char sample_text[MAX_NAME] = {};
bNode *crypto_node;
CryptomatteSession *cryptomatte_session;
ViewportColorSampleSession *viewport_session;
bNode *crypto_node = nullptr;
CryptomatteSession *cryptomatte_session = nullptr;
ViewportColorSampleSession *viewport_session = nullptr;
};
static void eyedropper_draw_cb(const wmWindow * /*window*/, void *arg)

View File

@@ -41,16 +41,16 @@
namespace blender::ui {
struct EyedropperColorband {
int event_xy_last[2];
int event_xy_last[2] = {};
/* Alpha is currently fixed at 1.0, may support in future. */
Vector<float4> color_buffer;
bool sample_start;
ColorBand init_color_band;
ColorBand *color_band;
PointerRNA ptr;
PropertyRNA *prop;
bool is_undo;
bool is_set;
Vector<float4> color_buffer = {};
bool sample_start = false;
ColorBand init_color_band = {};
ColorBand *color_band = nullptr;
PointerRNA ptr = {};
PropertyRNA *prop = nullptr;
bool is_undo = false;
bool is_set = false;
};
/* For user-data only. */
@@ -105,7 +105,7 @@ static bool eyedropper_colorband_init(bContext *C, wmOperator *op)
return false;
}
EyedropperColorband *eye = MEM_new<EyedropperColorband>(__func__, EyedropperColorband{});
EyedropperColorband *eye = MEM_new<EyedropperColorband>(__func__);
eye->color_band = band;
eye->init_color_band = *eye->color_band;
eye->ptr = rna_update_ptr;

View File

@@ -46,19 +46,19 @@
* \note #DataDropper is only internal name to avoid confusion with other kinds of eye-droppers.
*/
struct DataDropper {
PointerRNA ptr;
PropertyRNA *prop;
short idcode;
const char *idcode_name;
bool is_undo;
PointerRNA ptr = {};
PropertyRNA *prop = nullptr;
short idcode = 0;
const char *idcode_name = nullptr;
bool is_undo = false;
ID *init_id; /* for resetting on cancel */
ID *init_id = nullptr; /* for resetting on cancel */
ScrArea *cursor_area; /* Area under the cursor */
ARegionType *art;
void *draw_handle_pixel;
int name_pos[2];
char name[200];
ScrArea *cursor_area = nullptr; /* Area under the cursor */
ARegionType *art = nullptr;
void *draw_handle_pixel = nullptr;
int name_pos[2] = {};
char name[200] = {};
};
static void datadropper_draw_cb(const bContext * /*C*/, ARegion * /*region*/, void *arg)

View File

@@ -49,21 +49,21 @@
* \note #DepthDropper is only internal name to avoid confusion with other kinds of eye-droppers.
*/
struct DepthDropper {
PointerRNA ptr;
PropertyRNA *prop;
bool is_undo;
PointerRNA ptr = {};
PropertyRNA *prop = nullptr;
bool is_undo = false;
bool is_set;
float init_depth; /* For resetting on cancel. */
bool is_set = false;
float init_depth = 0.0f; /* For resetting on cancel. */
bool accum_start; /* Has mouse been pressed. */
float accum_depth;
int accum_tot;
bool accum_start = false; /* Has mouse been pressed. */
float accum_depth = 0.0f;
int accum_tot = 0;
ARegionType *art;
void *draw_handle_pixel;
int name_pos[2];
char name[200];
ARegionType *art = nullptr;
void *draw_handle_pixel = nullptr;
int name_pos[2] = {};
char name[200] = {};
};
static void depthdropper_draw_cb(const bContext * /*C*/, ARegion * /*region*/, void *arg)

View File

@@ -37,10 +37,10 @@
struct DriverDropper {
/* Destination property (i.e. where we'll add a driver) */
PointerRNA ptr;
PropertyRNA *prop;
int index;
bool is_undo;
PointerRNA ptr = {};
PropertyRNA *prop = nullptr;
int index = 0;
bool is_undo = false;
/* TODO: new target? */
};

View File

@@ -61,17 +61,17 @@ enum class MaterialMode : int8_t {
};
struct EyedropperGreasePencil {
ColorManagedDisplay *display;
ColorManagedDisplay *display = nullptr;
bool accum_start; /* has mouse been pressed */
float3 accum_col;
int accum_tot;
float3 color;
bool accum_start = false; /* has mouse been pressed */
float3 accum_col = {};
int accum_tot = 0;
float3 color = {};
/** Mode */
EyeMode mode;
EyeMode mode = EyeMode::Material;
/** Material Mode */
MaterialMode mat_mode;
MaterialMode mat_mode = MaterialMode::Stroke;
};
/* Helper: Draw status message while the user is running the operator */