Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 7 additions & 4 deletions modules/worldscape_3d/editor/menu.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -66,10 +66,13 @@ WorldScape3DMenu::WorldScape3DMenu(WorldScape3DEditorPlugin *plugin) :
p->connect("id_pressed", callable_mp(this, &WorldScape3DMenu::on_menu_entry));
}

WorldScape3DMenu::~WorldScape3DMenu() {
_baker->queue_free();
_packer_dialog->queue_free();
_dir_setup->queue_free();
void WorldScape3DMenu::_notification(int what) {
if (what == NOTIFICATION_PREDELETE) {
// Child pointers are still valid here, before Node's predelete notification.
memdelete(_baker);
memdelete(_packer_dialog);
memdelete(_dir_setup);
}
}

void WorldScape3DMenu::pressed() {
Expand Down
2 changes: 1 addition & 1 deletion modules/worldscape_3d/editor/menu.h
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ class WorldScape3DMenu final : public MenuButton {
};

explicit WorldScape3DMenu(WorldScape3DEditorPlugin *plugin);
~WorldScape3DMenu() override;
void _notification(int what);

void pressed() override;

Expand Down
16 changes: 5 additions & 11 deletions modules/worldscape_3d/editor/menu/baker.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -278,18 +278,11 @@ void BakerLODDialog::on_lod_box_value_changed(real_t) {
_lod = static_cast<int>(_lodbox->get_value());
}

BakerLODDialog::~BakerLODDialog() {
_description_label->queue_free();
_lodbox->queue_free();
_label->queue_free();
_hbox->queue_free();
_vbox->queue_free();
_margin->queue_free();
}

void BakerLODDialog::_notification(int what) {
if (what == NOTIFICATION_POSTINITIALIZE) {
init();
} else if (what == NOTIFICATION_PREDELETE) {
memdelete(_margin);
}
}

Expand Down Expand Up @@ -563,8 +556,9 @@ Baker::Baker(WorldScape3DEditorPlugin *plugin) :
}

Baker::~Baker() {
_confirm_dlg->queue_free();
_bake_lod_dlg->queue_free();
// These dialogs are unparented while hidden, so Node cannot release them.
memdelete(_confirm_dlg);
memdelete(_bake_lod_dlg);
}

Vector<WorldScape3D *> Baker::find_nav_region_terrains(NavigationRegion3D *nav_region) const {
Expand Down
2 changes: 0 additions & 2 deletions modules/worldscape_3d/editor/menu/baker.h
Original file line number Diff line number Diff line change
Expand Up @@ -64,8 +64,6 @@ class BakerLODDialog final : public ConfirmationDialog {
void on_lod_box_value_changed(real_t value);

public:
~BakerLODDialog() override;

void set_description(const String &description) { _description = description; }

int get_lod() const { return _lod; }
Expand Down
43 changes: 13 additions & 30 deletions modules/worldscape_3d/editor/menu/channel_packer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -132,9 +132,11 @@ class ChannelSelector final : public HBoxContainer {
add_child(_option);
}

~ChannelSelector() override {
_option->queue_free();
_label->queue_free();
void _notification(int what) {
if (what == NOTIFICATION_PREDELETE) {
memdelete(_option);
memdelete(_label);
}
}

void set_channels(int used_channels) {
Expand Down Expand Up @@ -420,21 +422,6 @@ class ChannelPanel final : public PanelContainer {
setup_layout();
}

~ChannelPanel() override {
_height_label->queue_free();
_width_label->queue_free();
_wh_hbox->queue_free();
_margin->queue_free();
_texture_button->queue_free();
_preview->queue_free();
_preview_panel->queue_free();
_pick_btn->queue_free();
_path_edit->queue_free();
_label->queue_free();
_outer_hbox->queue_free();
_vbox->queue_free();
}

void add(Control *control) {
if (_vbox2) {
_vbox2->add_child(control);
Expand Down Expand Up @@ -515,6 +502,11 @@ class ChannelPanel final : public PanelContainer {
void _notification(const int what) {
if (what == NOTIFICATION_ENTER_TREE) {
init();
} else if (what == NOTIFICATION_PREDELETE) {
memdelete(_outer_margin);
if (_open_file_dialog) {
memdelete(_open_file_dialog);
}
}
}
};
Expand Down Expand Up @@ -654,21 +646,12 @@ ChannelPackerDialog::ChannelPackerDialog() {
init_file_dialog();
}

ChannelPackerDialog::~ChannelPackerDialog() {
_general_options_panel->queue_free();
_roughness_panel->queue_free();
_normal_panel->queue_free();
_bottom_hbox->queue_free();
_height_panel->queue_free();
_albedo_panel->queue_free();
_top_hbox->queue_free();
_vbox->queue_free();
_margin->queue_free();
}

void ChannelPackerDialog::_notification(const int what) {
if (what == NOTIFICATION_POSTINITIALIZE) {
init();
} else if (what == NOTIFICATION_PREDELETE) {
memdelete(_vbox);
memdelete(_margin);
}
}

Expand Down
1 change: 0 additions & 1 deletion modules/worldscape_3d/editor/menu/channel_packer.h
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,6 @@ class ChannelPackerDialog : public AcceptDialog {

public:
ChannelPackerDialog();
~ChannelPackerDialog() override;

void _notification(int what);

Expand Down
16 changes: 5 additions & 11 deletions modules/worldscape_3d/editor/menu/directory_setup.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -104,15 +104,10 @@ DirectorySetupDialog::DirectorySetupDialog() {
ConfirmationDialog::set_visible(true);
}

DirectorySetupDialog::~DirectorySetupDialog() {
_spacer->queue_free();
_select_dir_btn->queue_free();
_select_dir_le->queue_free();
_dir_hbox->queue_free();
_dir_label->queue_free();
_instructions->queue_free();
_vbox->queue_free();
_margin->queue_free();
void DirectorySetupDialog::_notification(int what) {
if (what == NOTIFICATION_PREDELETE) {
memdelete(_margin);
}
}

void DirectorySetup::setup_layout() {
Expand Down Expand Up @@ -144,8 +139,7 @@ DirectorySetup::DirectorySetup(WorldScape3DEditorPlugin *plugin) :
}

DirectorySetup::~DirectorySetup() {
_file_dialog->queue_free();
_dialog->queue_free();
memdelete(_dialog);
}

void DirectorySetup::directory_setup_popup() {
Expand Down
2 changes: 1 addition & 1 deletion modules/worldscape_3d/editor/menu/directory_setup.h
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ class DirectorySetupDialog final : public ConfirmationDialog {

public:
DirectorySetupDialog();
~DirectorySetupDialog() override;
void _notification(int what);

Button *get_dir_button() const { return _select_dir_btn; }
LineEdit *get_dir_edit() const { return _select_dir_le; }
Expand Down
64 changes: 26 additions & 38 deletions modules/worldscape_3d/editor/ui/worldscape_3d_asset_dock.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -110,22 +110,6 @@ ListEntry::ListEntry(const WorldScape3DAssets::AssetType type) {
_button_enabled = memnew(TextureButton);
}

ListEntry::~ListEntry() {
if (_count_label) {
_count_label->queue_free();
}
if (_name_label) {
_name_label->queue_free();
}
_button_enabled->queue_free();
_spacer->queue_free();
_button_edit->queue_free();
_button_clear->queue_free();
_button_row->queue_free();
_margin->queue_free();
_label_rows->queue_free();
}

void ListEntry::_bind_methods() {
ADD_SIGNAL(MethodInfo("hovered"));
ADD_SIGNAL(MethodInfo("selected"));
Expand All @@ -135,6 +119,22 @@ void ListEntry::_bind_methods() {

void ListEntry::_notification(int what) {
switch (what) {
case NOTIFICATION_PREDELETE:
// Also release controls that have not been parented by init().
if (_count_label) {
memdelete(_count_label);
}
if (_name_label) {
memdelete(_name_label);
}
memdelete(_button_enabled);
memdelete(_spacer);
memdelete(_button_edit);
memdelete(_button_clear);
memdelete(_button_row);
memdelete(_margin);
memdelete(_label_rows);
break;
case NOTIFICATION_POST_ENTER_TREE:
init();
break;
Expand Down Expand Up @@ -499,10 +499,6 @@ ListContainer::ListContainer(WorldScape3DEditorPlugin *plugin) :
set_h_size_flags(SIZE_EXPAND_FILL);
}

ListContainer::~ListContainer() {
clear();
}

void ListContainer::clear() {
for (auto *e : _entries) {
e->queue_free();
Expand Down Expand Up @@ -719,6 +715,11 @@ void ListContainer::redraw() {
void ListContainer::_notification(int what) {
if (what == NOTIFICATION_SORT_CHILDREN) {
redraw();
} else if (what == NOTIFICATION_PREDELETE) {
for (ListEntry *entry : _entries) {
memdelete(entry);
}
_entries.clear();
}
}

Expand Down Expand Up @@ -950,24 +951,6 @@ WorldScape3DAssetDock::WorldScape3DAssetDock(WorldScape3DEditorPlugin *plugin) :
_initialized = true;
}

WorldScape3DAssetDock::~WorldScape3DAssetDock() {
_mesh_list->clear();
_mesh_list->queue_free();
_texture_list->clear();
_texture_list->queue_free();

_placement_opt->queue_free();
_floating_btn->queue_free();
_pinned_btn->queue_free();
_size_slider->queue_free();
_box->queue_free();
_buttons->queue_free();
_textures_btn->queue_free();
_meshes_btn->queue_free();
_asset_container->queue_free();
_confirm_dialog->queue_free();
}

// Dock placement

void WorldScape3DAssetDock::set_slot(const int slot) {
Expand Down Expand Up @@ -1329,6 +1312,11 @@ void WorldScape3DAssetDock::_bind_methods() {
void WorldScape3DAssetDock::_notification(int what) {
if (what == NOTIFICATION_POSTINITIALIZE) {
init();
} else if (what == NOTIFICATION_PREDELETE) {
memdelete(_box);
if (_confirm_dialog) {
memdelete(_confirm_dialog);
}
}
}

Expand Down
3 changes: 0 additions & 3 deletions modules/worldscape_3d/editor/ui/worldscape_3d_asset_dock.h
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,6 @@ class ListEntry : public MarginContainer {

public:
explicit ListEntry(WorldScape3DAssets::AssetType type);
~ListEntry() override;

void set_assets(Ref<WorldScape3DAssets> assets_list) {
_asset_list = assets_list;
Expand Down Expand Up @@ -148,7 +147,6 @@ class ListContainer : public Container {

public:
explicit ListContainer(WorldScape3DEditorPlugin *plugin);
~ListContainer() override;

void redraw();
void clear();
Expand Down Expand Up @@ -245,7 +243,6 @@ class WorldScape3DAssetDock final : public PanelContainer {

public:
explicit WorldScape3DAssetDock(WorldScape3DEditorPlugin *plugin);
~WorldScape3DAssetDock() override;

ListContainer *get_current_list() const { return _current_list; }
ConfirmationDialog *get_confirmation_dialog() const { return _confirm_dialog; }
Expand Down
13 changes: 2 additions & 11 deletions modules/worldscape_3d/editor/ui/worldscape_3d_tools.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -101,16 +101,6 @@ constexpr int NO_SAVE = 0x20; // Don't save this in EditorSettings
WorldScape3DToolSettings::WorldScape3DToolSettings(WorldScape3DEditorPlugin *plugin) :
_plugin{ plugin } {}

WorldScape3DToolSettings::~WorldScape3DToolSettings() {
_select_brush_button->queue_free();
_scale_list->queue_free();
_color_list->queue_free();
_rotation_list->queue_free();
_height_list->queue_free();
_advanced_list->queue_free();
_main_list->queue_free();
}

class ToolSubMenu : public PopupPanel {
GDCLASS(ToolSubMenu, PopupPanel)

Expand Down Expand Up @@ -640,9 +630,10 @@ void WorldScape3DToolSettings::_bind_methods() {
}

void WorldScape3DToolSettings::_notification(int what) {
PanelContainer::_notification(what);
if (what == NOTIFICATION_POST_ENTER_TREE) {
init();
} else if (what == NOTIFICATION_PREDELETE && _main_list) {
memdelete(_main_list);
Comment thread
coderabbitai[bot] marked this conversation as resolved.
}
}

Expand Down
1 change: 0 additions & 1 deletion modules/worldscape_3d/editor/ui/worldscape_3d_tools.h
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,6 @@ class WorldScape3DToolSettings : public PanelContainer {
};

explicit WorldScape3DToolSettings(WorldScape3DEditorPlugin *plugin);
~WorldScape3DToolSettings() override;

void on_show_submenu(bool toggled, Button *button);

Expand Down
16 changes: 9 additions & 7 deletions modules/worldscape_3d/editor/ui/worldscape_3d_ui.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -309,14 +309,11 @@ WorldScape3DUI::~WorldScape3DUI() {
_plugin->remove_control_from_container(CONTAINER_SPATIAL_EDITOR_BOTTOM, _tool_settings);
_plugin->remove_control_from_container(CONTAINER_SPATIAL_EDITOR_SIDE_LEFT, _toolbar);
}
if (_editor_decal_timer) {
_editor_decal_timer->queue_free();
}
if (_toolbar) {
_toolbar->queue_free();
memdelete(_toolbar);
}
if (_menu) {
_menu->queue_free();
memdelete(_menu);
}
if (_tool_settings) {
if (_tool_settings->is_connected("setting_changed", callable_mp(this, &WorldScape3DUI::on_setting_changed))) {
Expand All @@ -325,7 +322,7 @@ WorldScape3DUI::~WorldScape3DUI() {
if (_tool_settings->is_connected("picking", callable_mp(_tool_settings, &WorldScape3DToolSettings::on_pick))) {
_tool_settings->disconnect("picking", callable_mp(_tool_settings, &WorldScape3DToolSettings::on_pick));
}
_tool_settings->queue_free();
memdelete(_tool_settings);
}
}

Expand Down Expand Up @@ -941,8 +938,13 @@ void WorldScape3DUI::_bind_methods() {
}

void WorldScape3DUI::_notification(int what) {
Node::_notification(what);
switch (what) {
case NOTIFICATION_PREDELETE: {
if (_editor_decal_timer) {
memdelete(_editor_decal_timer);
}
break;
}
case NOTIFICATION_ENTER_TREE: {
on_tool_changed(WorldScape3DEditor::Tool::REGION, WorldScape3DEditor::Operation::ADD);
break;
Expand Down
Loading
Loading