Skip to content

Commit

Permalink
Merge pull request #43742 from qarmin/editor_modules_default_values
Browse files Browse the repository at this point in the history
Initialize class/struct variables with default values in platform/ and editor/
  • Loading branch information
akien-mga authored Dec 8, 2020
2 parents edb3686 + e1811b6 commit 90bdba5
Show file tree
Hide file tree
Showing 87 changed files with 411 additions and 540 deletions.
2 changes: 1 addition & 1 deletion core/doc_data.h
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ class DocData {
struct ConstantDoc {
String name;
String value;
bool is_value_valid;
bool is_value_valid = false;
String enumeration;
String description;
bool operator<(const ConstantDoc &p_const) const {
Expand Down
6 changes: 3 additions & 3 deletions editor/animation_bezier_editor.h
Original file line number Diff line number Diff line change
Expand Up @@ -111,10 +111,10 @@ class AnimationBezierTrackEdit : public Control {
Vector2 menu_insert_key;

struct AnimMoveRestore {
int track;
float time;
int track = 0;
float time = 0;
Variant key;
float transition;
float transition = 0;
};

AnimationTrackEditor *editor;
Expand Down
40 changes: 13 additions & 27 deletions editor/animation_track_editor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ class AnimationTrackKeyEdit : public Object {
GDCLASS(AnimationTrackKeyEdit, Object);

public:
bool setting;
bool setting = false;

bool _hide_script_from_inspector() {
return true;
Expand Down Expand Up @@ -622,15 +622,15 @@ class AnimationTrackKeyEdit : public Object {
}
}

UndoRedo *undo_redo;
UndoRedo *undo_redo = nullptr;
Ref<Animation> animation;
int track;
float key_ofs;
Node *root_path;
int track = -1;
float key_ofs = 0;
Node *root_path = nullptr;

PropertyInfo hint;
NodePath base;
bool use_fps;
bool use_fps = false;

void notify_change() {
_change_notify();
Expand All @@ -644,21 +644,13 @@ class AnimationTrackKeyEdit : public Object {
use_fps = p_enable;
_change_notify();
}

AnimationTrackKeyEdit() {
use_fps = false;
key_ofs = 0;
track = -1;
setting = false;
root_path = nullptr;
}
};

class AnimationMultiTrackKeyEdit : public Object {
GDCLASS(AnimationMultiTrackKeyEdit, Object);

public:
bool setting;
bool setting = false;

bool _hide_script_from_inspector() {
return true;
Expand Down Expand Up @@ -1276,11 +1268,11 @@ class AnimationMultiTrackKeyEdit : public Object {
Map<int, NodePath> base_map;
PropertyInfo hint;

Node *root_path;
Node *root_path = nullptr;

bool use_fps;
bool use_fps = false;

UndoRedo *undo_redo;
UndoRedo *undo_redo = nullptr;

void notify_change() {
_change_notify();
Expand All @@ -1294,12 +1286,6 @@ class AnimationMultiTrackKeyEdit : public Object {
use_fps = p_enable;
_change_notify();
}

AnimationMultiTrackKeyEdit() {
use_fps = false;
setting = false;
root_path = nullptr;
}
};

void AnimationTimelineEdit::_zoom_changed(double) {
Expand Down Expand Up @@ -4669,10 +4655,10 @@ void AnimationTrackEditor::_move_selection(float p_offset) {
}

struct _AnimMoveRestore {
int track;
float time;
int track = 0;
float time = 0;
Variant key;
float transition;
float transition = 0;
};
//used for undo/redo

Expand Down
28 changes: 14 additions & 14 deletions editor/animation_track_editor.h
Original file line number Diff line number Diff line change
Expand Up @@ -253,8 +253,8 @@ class AnimationTrackEditGroup : public Control {
Ref<Texture2D> icon;
String node_name;
NodePath node;
Node *root;
AnimationTimelineEdit *timeline;
Node *root = nullptr;
AnimationTimelineEdit *timeline = nullptr;

void _zoom_changed();

Expand Down Expand Up @@ -354,10 +354,10 @@ class AnimationTrackEditor : public VBoxContainer {
struct InsertData {
Animation::TrackType type;
NodePath path;
int track_idx;
int track_idx = 0;
Variant value;
String query;
bool advance;
bool advance = false;
}; /* insert_data;*/

Label *insert_confirm_text;
Expand Down Expand Up @@ -392,13 +392,13 @@ class AnimationTrackEditor : public VBoxContainer {
//selection

struct SelectedKey {
int track;
int key;
int track = 0;
int key = 0;
bool operator<(const SelectedKey &p_key) const { return track == p_key.track ? key < p_key.key : track < p_key.track; };
};

struct KeyInfo {
float pos;
float pos = 0;
};

Map<SelectedKey, KeyInfo> selection;
Expand Down Expand Up @@ -467,15 +467,15 @@ class AnimationTrackEditor : public VBoxContainer {
struct TrackClipboard {
NodePath full_path;
NodePath base_path;
Animation::TrackType track_type;
Animation::InterpolationType interp_type;
Animation::UpdateMode update_mode;
bool loop_wrap;
bool enabled;
Animation::TrackType track_type = Animation::TrackType::TYPE_ANIMATION;
Animation::InterpolationType interp_type = Animation::InterpolationType::INTERPOLATION_CUBIC;
Animation::UpdateMode update_mode = Animation::UpdateMode::UPDATE_CAPTURE;
bool loop_wrap = false;
bool enabled = false;

struct Key {
float time;
float transition;
float time = 0;
float transition = 0;
Variant value;
};
Vector<Key> keys;
Expand Down
4 changes: 2 additions & 2 deletions editor/audio_stream_preview.h
Original file line number Diff line number Diff line change
Expand Up @@ -60,9 +60,9 @@ class AudioStreamPreviewGenerator : public Node {
Ref<AudioStreamPreview> preview;
Ref<AudioStream> base_stream;
Ref<AudioStreamPlayback> playback;
volatile bool generating;
volatile bool generating = false;
ObjectID id;
Thread *thread;
Thread *thread = nullptr;
};

Map<ObjectID, Preview> previews;
Expand Down
2 changes: 2 additions & 0 deletions editor/code_editor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,8 @@ GotoLineDialog::GotoLineDialog() {
register_text_enter(line);
text_editor = nullptr;

line_label = nullptr;

set_hide_on_ok(false);
}

Expand Down
27 changes: 11 additions & 16 deletions editor/debugger/editor_profiler.h
Original file line number Diff line number Diff line change
Expand Up @@ -45,27 +45,27 @@ class EditorProfiler : public VBoxContainer {

public:
struct Metric {
bool valid;
bool valid = false;

int frame_number;
float frame_time;
float idle_time;
float physics_time;
float physics_frame_time;
int frame_number = 0;
float frame_time = 0;
float idle_time = 0;
float physics_time = 0;
float physics_frame_time = 0;

struct Category {
StringName signature;
String name;
float total_time; //total for category
float total_time = 0; //total for category

struct Item {
StringName signature;
String name;
String script;
int line;
float self;
float total;
int calls;
int line = 0;
float self = 0;
float total = 0;
int calls = 0;
};

Vector<Item> items;
Expand All @@ -75,11 +75,6 @@ class EditorProfiler : public VBoxContainer {

Map<StringName, Category *> category_ptrs;
Map<StringName, Category::Item *> item_ptrs;

Metric() {
valid = false;
frame_number = 0;
}
};

enum DisplayMode {
Expand Down
8 changes: 2 additions & 6 deletions editor/debugger/editor_visual_profiler.h
Original file line number Diff line number Diff line change
Expand Up @@ -46,9 +46,9 @@ class EditorVisualProfiler : public VBoxContainer {

public:
struct Metric {
bool valid;
bool valid = false;

uint64_t frame_number;
uint64_t frame_number = 0;

struct Area {
String name;
Expand All @@ -59,10 +59,6 @@ class EditorVisualProfiler : public VBoxContainer {
};

Vector<Area> areas;

Metric() {
valid = false;
}
};

enum DisplayTimeMode {
Expand Down
2 changes: 2 additions & 0 deletions editor/dependency_editor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -626,6 +626,8 @@ DependencyErrorDialog::DependencyErrorDialog() {
vb->add_child(text);
text->set_text(TTR("Which action should be taken?"));

mode = Mode::MODE_RESOURCE;

fdep = add_button(TTR("Fix Dependencies"), true, "fixdeps");

set_title(TTR("Errors loading!"));
Expand Down
12 changes: 6 additions & 6 deletions editor/editor_atlas_packer.h
Original file line number Diff line number Diff line change
Expand Up @@ -41,23 +41,23 @@ class EditorAtlasPacker {
struct Chart {
Vector<Vector2> vertices;
struct Face {
int vertex[3];
int vertex[3] = { 0 };
};
Vector<Face> faces;
bool can_transpose;
bool can_transpose = false;

Vector2 final_offset;
bool transposed;
bool transposed = false;
};

private:
struct PlottedBitmap {
int chart_index;
int chart_index = 0;
Vector2i offset;
int area;
int area = 0;
Vector<int> top_heights;
Vector<int> bottom_heights;
bool transposed;
bool transposed = false;

Vector2 final_pos;

Expand Down
16 changes: 8 additions & 8 deletions editor/editor_audio_buses.h
Original file line number Diff line number Diff line change
Expand Up @@ -61,13 +61,13 @@ class EditorAudioBus : public PanelContainer {
static const int CHANNELS_MAX = 4;

struct {
bool prev_active;
bool prev_active = false;

float peak_l;
float peak_r;
float peak_l = 0;
float peak_r = 0;

TextureProgress *vu_l;
TextureProgress *vu_r;
TextureProgress *vu_l = nullptr;
TextureProgress *vu_r = nullptr;
} channel[CHANNELS_MAX];

OptionButton *send;
Expand Down Expand Up @@ -214,9 +214,9 @@ class EditorAudioMeterNotches : public Control {

private:
struct AudioNotch {
float relative_position;
float db_value;
bool render_db_value;
float relative_position = 0;
float db_value = 0;
bool render_db_value = false;

_FORCE_INLINE_ AudioNotch(float r_pos, float db_v, bool rndr_val) {
relative_position = r_pos;
Expand Down
14 changes: 4 additions & 10 deletions editor/editor_autoload_settings.h
Original file line number Diff line number Diff line change
Expand Up @@ -50,20 +50,14 @@ class EditorAutoloadSettings : public VBoxContainer {
struct AutoLoadInfo {
String name;
String path;
bool is_singleton;
bool in_editor;
int order;
Node *node;
bool is_singleton = false;
bool in_editor = false;
int order = 0;
Node *node = nullptr;

bool operator==(const AutoLoadInfo &p_info) const {
return order == p_info.order;
}

AutoLoadInfo() {
is_singleton = false;
in_editor = false;
node = nullptr;
}
};

List<AutoLoadInfo> autoload_cache;
Expand Down
Loading

0 comments on commit 90bdba5

Please sign in to comment.