summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--doc/classes/EditorResourcePicker.xml2
-rw-r--r--editor/editor_help.cpp46
-rw-r--r--editor/editor_help.h9
-rw-r--r--editor/editor_node.cpp2
-rw-r--r--editor/editor_resource_picker.cpp12
-rw-r--r--editor/editor_resource_picker.h3
-rw-r--r--editor/plugins/text_control_editor_plugin.cpp199
-rw-r--r--editor/plugins/text_control_editor_plugin.h2
-rw-r--r--scene/gui/graph_edit.cpp14
-rw-r--r--scene/gui/graph_edit.h2
-rw-r--r--scene/gui/rich_text_label.cpp1
-rw-r--r--scene/main/viewport.cpp4
-rw-r--r--scene/main/viewport.h3
13 files changed, 233 insertions, 66 deletions
diff --git a/doc/classes/EditorResourcePicker.xml b/doc/classes/EditorResourcePicker.xml
index b26b6f9527..f374b5f425 100644
--- a/doc/classes/EditorResourcePicker.xml
+++ b/doc/classes/EditorResourcePicker.xml
@@ -11,7 +11,7 @@
</tutorials>
<methods>
<method name="_handle_menu_selected" qualifiers="virtual">
- <return type="void" />
+ <return type="bool" />
<argument index="0" name="id" type="int" />
<description>
This virtual method can be implemented to handle context menu items not handled by default. See [method _set_create_options].
diff --git a/editor/editor_help.cpp b/editor/editor_help.cpp
index 5178f50553..06e3a63f4a 100644
--- a/editor/editor_help.cpp
+++ b/editor/editor_help.cpp
@@ -1724,14 +1724,34 @@ void EditorHelp::_add_text(const String &p_bbcode) {
_add_text_to_rt(p_bbcode, class_desc);
}
-void EditorHelp::generate_doc() {
- doc = memnew(DocTools);
- doc->generate(true);
+Thread EditorHelp::thread;
+
+void EditorHelp::_wait_for_thread() {
+ if (thread.is_started()) {
+ thread.wait_to_finish();
+ }
+}
+
+void EditorHelp::_gen_doc_thread(void *p_udata) {
DocTools compdoc;
compdoc.load_compressed(_doc_data_compressed, _doc_data_compressed_size, _doc_data_uncompressed_size);
doc->merge_from(compdoc); //ensure all is up to date
}
+static bool doc_gen_use_threads = true;
+
+void EditorHelp::generate_doc() {
+ doc = memnew(DocTools);
+ // Not doable on threads unfortunately, since it instantiates all sorts of classes to get default values.
+ doc->generate(true);
+
+ if (doc_gen_use_threads) {
+ thread.start(_gen_doc_thread, nullptr);
+ } else {
+ _gen_doc_thread(nullptr);
+ }
+}
+
void EditorHelp::_toggle_scripts_pressed() {
ScriptEditor::get_singleton()->toggle_scripts_panel();
update_toggle_scripts_button();
@@ -1741,6 +1761,7 @@ void EditorHelp::_notification(int p_what) {
switch (p_what) {
case NOTIFICATION_READY:
case EditorSettings::NOTIFICATION_EDITOR_SETTINGS_CHANGED: {
+ _wait_for_thread();
_update_doc();
} break;
case NOTIFICATION_THEME_CHANGED: {
@@ -1758,20 +1779,32 @@ void EditorHelp::_notification(int p_what) {
}
void EditorHelp::go_to_help(const String &p_help) {
+ _wait_for_thread();
_help_callback(p_help);
}
void EditorHelp::go_to_class(const String &p_class, int p_scroll) {
+ _wait_for_thread();
_goto_desc(p_class, p_scroll);
}
void EditorHelp::update_doc() {
+ _wait_for_thread();
ERR_FAIL_COND(!doc->class_list.has(edited_class));
ERR_FAIL_COND(!doc->class_list[edited_class].is_script_doc);
_update_doc();
}
+void EditorHelp::cleanup_doc() {
+ _wait_for_thread();
+ if (doc_gen_use_threads) {
+ thread.wait_to_finish();
+ }
+ memdelete(doc);
+}
+
Vector<Pair<String, int>> EditorHelp::get_sections() {
+ _wait_for_thread();
Vector<Pair<String, int>> sections;
for (int i = 0; i < section_line.size(); i++) {
@@ -1781,11 +1814,13 @@ Vector<Pair<String, int>> EditorHelp::get_sections() {
}
void EditorHelp::scroll_to_section(int p_section_index) {
+ _wait_for_thread();
int line = section_line[p_section_index].second;
class_desc->scroll_to_paragraph(line);
}
void EditorHelp::popup_search() {
+ _wait_for_thread();
find_bar->popup_search();
}
@@ -1864,6 +1899,11 @@ EditorHelp::EditorHelp() {
EditorHelp::~EditorHelp() {
}
+DocTools *EditorHelp::get_doc_data() {
+ _wait_for_thread();
+ return doc;
+}
+
void EditorHelpBit::_go_to_help(String p_what) {
EditorNode::get_singleton()->set_visible_editor(EditorNode::EDITOR_SCRIPT);
ScriptEditor::get_singleton()->goto_help(p_what);
diff --git a/editor/editor_help.h b/editor/editor_help.h
index f74c64bb7c..eb879c6d39 100644
--- a/editor/editor_help.h
+++ b/editor/editor_help.h
@@ -31,6 +31,7 @@
#ifndef EDITOR_HELP_H
#define EDITOR_HELP_H
+#include "core/os/thread.h"
#include "editor/code_editor.h"
#include "editor/doc_tools.h"
#include "editor/editor_plugin.h"
@@ -164,13 +165,19 @@ class EditorHelp : public VBoxContainer {
String _fix_constant(const String &p_constant) const;
void _toggle_scripts_pressed();
+ static Thread thread;
+
+ static void _wait_for_thread();
+ static void _gen_doc_thread(void *p_udata);
+
protected:
void _notification(int p_what);
static void _bind_methods();
public:
static void generate_doc();
- static DocTools *get_doc_data() { return doc; }
+ static DocTools *get_doc_data();
+ static void cleanup_doc();
void go_to_help(const String &p_help);
void go_to_class(const String &p_class, int p_scroll = 0);
diff --git a/editor/editor_node.cpp b/editor/editor_node.cpp
index cca8bc1b29..afd5407f37 100644
--- a/editor/editor_node.cpp
+++ b/editor/editor_node.cpp
@@ -7211,7 +7211,7 @@ EditorNode::~EditorNode() {
EditorTranslationParser::get_singleton()->clean_parsers();
remove_print_handler(&print_handler);
- memdelete(EditorHelp::get_doc_data());
+ EditorHelp::cleanup_doc();
memdelete(editor_selection);
memdelete(editor_plugins_over);
memdelete(editor_plugins_force_over);
diff --git a/editor/editor_resource_picker.cpp b/editor/editor_resource_picker.cpp
index 421d16313a..c649162d7e 100644
--- a/editor/editor_resource_picker.cpp
+++ b/editor/editor_resource_picker.cpp
@@ -387,8 +387,7 @@ void EditorResourcePicker::_edit_menu_cbk(int p_which) {
void EditorResourcePicker::set_create_options(Object *p_menu_node) {
_ensure_resource_menu();
// If a subclass implements this method, use it to replace all create items.
- if (get_script_instance() && get_script_instance()->has_method("_set_create_options")) {
- get_script_instance()->call("_set_create_options", p_menu_node);
+ if (GDVIRTUAL_CALL(_set_create_options, p_menu_node)) {
return;
}
@@ -444,8 +443,9 @@ void EditorResourcePicker::set_create_options(Object *p_menu_node) {
}
bool EditorResourcePicker::handle_menu_selected(int p_which) {
- if (get_script_instance() && get_script_instance()->has_method("_handle_menu_selected")) {
- return get_script_instance()->call("_handle_menu_selected", p_which);
+ bool success;
+ if (GDVIRTUAL_CALL(_handle_menu_selected, p_which, success)) {
+ return success;
}
return false;
@@ -706,8 +706,8 @@ void EditorResourcePicker::_bind_methods() {
ClassDB::bind_method(D_METHOD("set_editable", "enable"), &EditorResourcePicker::set_editable);
ClassDB::bind_method(D_METHOD("is_editable"), &EditorResourcePicker::is_editable);
- ClassDB::add_virtual_method(get_class_static(), MethodInfo("_set_create_options", PropertyInfo(Variant::OBJECT, "menu_node")));
- ClassDB::add_virtual_method(get_class_static(), MethodInfo("_handle_menu_selected", PropertyInfo(Variant::INT, "id")));
+ GDVIRTUAL_BIND(_set_create_options, "menu_node");
+ GDVIRTUAL_BIND(_handle_menu_selected, "id");
ADD_PROPERTY(PropertyInfo(Variant::STRING, "base_type"), "set_base_type", "get_base_type");
ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "edited_resource", PROPERTY_HINT_RESOURCE_TYPE, "Resource", PROPERTY_USAGE_NONE), "set_edited_resource", "get_edited_resource");
diff --git a/editor/editor_resource_picker.h b/editor/editor_resource_picker.h
index e693eeba14..8ffa52f14f 100644
--- a/editor/editor_resource_picker.h
+++ b/editor/editor_resource_picker.h
@@ -102,6 +102,9 @@ protected:
static void _bind_methods();
void _notification(int p_what);
+ GDVIRTUAL1(_set_create_options, Object *)
+ GDVIRTUAL1R(bool, _handle_menu_selected, int)
+
public:
static void clear_caches();
diff --git a/editor/plugins/text_control_editor_plugin.cpp b/editor/plugins/text_control_editor_plugin.cpp
index bef93c161a..a51b5d3e03 100644
--- a/editor/plugins/text_control_editor_plugin.cpp
+++ b/editor/plugins/text_control_editor_plugin.cpp
@@ -53,6 +53,10 @@ void TextControlEditor::_notification(int p_notification) {
}
}
+void TextControlEditor::_bind_methods() {
+ ClassDB::bind_method(D_METHOD("_update_control"), &TextControlEditor::_update_control);
+}
+
void TextControlEditor::_find_resources(EditorFileSystemDirectory *p_dir) {
for (int i = 0; i < p_dir->get_subdir_count(); i++) {
_find_resources(p_dir->get_subdir(i));
@@ -179,8 +183,13 @@ void TextControlEditor::_update_control() {
}
// Get other theme overrides.
+ font_size_list->set_block_signals(true);
font_size_list->set_value(edited_control->get_theme_font_size(edited_font_size));
+ font_size_list->set_block_signals(false);
+
+ outline_size_list->set_block_signals(true);
outline_size_list->set_value(edited_control->get_theme_constant("outline_size"));
+ outline_size_list->set_block_signals(false);
font_color_picker->set_pick_color(edited_control->get_theme_color(edited_color));
outline_color_picker->set_pick_color(edited_control->get_theme_color("font_outline_color"));
@@ -188,7 +197,6 @@ void TextControlEditor::_update_control() {
}
void TextControlEditor::_font_selected(int p_id) {
- _update_styles_menu();
_set_font();
}
@@ -197,70 +205,177 @@ void TextControlEditor::_font_style_selected(int p_id) {
}
void TextControlEditor::_set_font() {
- if (edited_control) {
- if (font_list->get_selected_id() == FONT_INFO_THEME_DEFAULT) {
- // Remove font override.
- edited_control->remove_theme_font_override(edited_font);
- return;
- } else if (font_list->get_selected_id() == FONT_INFO_USER_CUSTOM) {
- // Restore "custom_font".
- edited_control->add_theme_font_override(edited_font, custom_font);
- return;
- } else {
- // Load new font resource using selected name and style.
- String name = font_list->get_item_text(font_list->get_selected());
- String sty = font_style_list->get_item_text(font_style_list->get_selected());
- if (sty.is_empty()) {
- sty = "Default";
- }
- if (fonts.has(name)) {
- Ref<FontData> fd = ResourceLoader::load(fonts[name][sty]);
- if (fd.is_valid()) {
- Ref<Font> f;
- f.instantiate();
- f->add_data(fd);
- edited_control->add_theme_font_override(edited_font, f);
- }
+ if (!edited_control) {
+ return;
+ }
+
+ UndoRedo *ur = EditorNode::get_singleton()->get_undo_redo();
+ ur->create_action(TTR("Set Font"));
+
+ if (font_list->get_selected_id() == FONT_INFO_THEME_DEFAULT) {
+ // Remove font override.
+ ur->add_do_method(edited_control, "remove_theme_font_override", edited_font);
+ } else if (font_list->get_selected_id() == FONT_INFO_USER_CUSTOM) {
+ // Restore "custom_font".
+ ur->add_do_method(edited_control, "add_theme_font_override", edited_font, custom_font);
+ } else {
+ // Load new font resource using selected name and style.
+ String name = font_list->get_item_text(font_list->get_selected());
+ String style = font_style_list->get_item_text(font_style_list->get_selected());
+ if (style.is_empty()) {
+ style = "Default";
+ }
+
+ if (fonts.has(name)) {
+ Ref<FontData> fd = ResourceLoader::load(fonts[name][style]);
+ if (fd.is_valid()) {
+ Ref<Font> font;
+ font.instantiate();
+ font->add_data(fd);
+ ur->add_do_method(edited_control, "add_theme_font_override", edited_font, font);
}
}
}
+
+ if (edited_control->has_theme_font_override(edited_font)) {
+ ur->add_undo_method(edited_control, "add_theme_font_override", edited_font, edited_control->get_theme_font(edited_font));
+ } else {
+ ur->add_undo_method(edited_control, "remove_theme_font_override", edited_font);
+ }
+
+ ur->add_do_method(this, "_update_control");
+ ur->add_undo_method(this, "_update_control");
+
+ ur->commit_action();
}
void TextControlEditor::_font_size_selected(double p_size) {
- if (edited_control) {
- edited_control->add_theme_font_size_override(edited_font_size, p_size);
+ if (!edited_control) {
+ return;
+ }
+
+ UndoRedo *ur = EditorNode::get_singleton()->get_undo_redo();
+ ur->create_action(TTR("Set Font Size"));
+
+ ur->add_do_method(edited_control, "add_theme_font_size_override", edited_font_size, p_size);
+ if (edited_control->has_theme_font_size_override(edited_font_size)) {
+ ur->add_undo_method(edited_control, "add_theme_font_size_override", edited_font_size, edited_control->get_theme_font_size(edited_font_size));
+ } else {
+ ur->add_undo_method(edited_control, "remove_theme_font_size_override", edited_font_size);
}
+
+ ur->add_do_method(this, "_update_control");
+ ur->add_undo_method(this, "_update_control");
+
+ ur->commit_action();
}
void TextControlEditor::_outline_size_selected(double p_size) {
- if (edited_control) {
- edited_control->add_theme_constant_override("outline_size", p_size);
+ if (!edited_control) {
+ return;
+ }
+
+ UndoRedo *ur = EditorNode::get_singleton()->get_undo_redo();
+ ur->create_action(TTR("Set Font Outline Size"));
+
+ ur->add_do_method(edited_control, "add_theme_constant_override", "outline_size", p_size);
+ if (edited_control->has_theme_constant_override("outline_size")) {
+ ur->add_undo_method(edited_control, "add_theme_constant_override", "outline_size", edited_control->get_theme_constant("outline_size"));
+ } else {
+ ur->add_undo_method(edited_control, "remove_theme_constant_override", "outline_size");
}
+
+ ur->add_do_method(this, "_update_control");
+ ur->add_undo_method(this, "_update_control");
+
+ ur->commit_action();
}
void TextControlEditor::_font_color_changed(const Color &p_color) {
- if (edited_control) {
- edited_control->add_theme_color_override(edited_color, p_color);
+ if (!edited_control) {
+ return;
+ }
+
+ UndoRedo *ur = EditorNode::get_singleton()->get_undo_redo();
+ ur->create_action(TTR("Set Font Color"), UndoRedo::MERGE_ENDS);
+
+ ur->add_do_method(edited_control, "add_theme_color_override", edited_color, p_color);
+ if (edited_control->has_theme_color_override(edited_color)) {
+ ur->add_undo_method(edited_control, "add_theme_color_override", edited_color, edited_control->get_theme_color(edited_color));
+ } else {
+ ur->add_undo_method(edited_control, "remove_theme_color_override", edited_color);
}
+
+ ur->add_do_method(this, "_update_control");
+ ur->add_undo_method(this, "_update_control");
+
+ ur->commit_action();
}
void TextControlEditor::_outline_color_changed(const Color &p_color) {
- if (edited_control) {
- edited_control->add_theme_color_override("font_outline_color", p_color);
+ if (!edited_control) {
+ return;
+ }
+
+ UndoRedo *ur = EditorNode::get_singleton()->get_undo_redo();
+ ur->create_action(TTR("Set Font Outline Color"), UndoRedo::MERGE_ENDS);
+
+ ur->add_do_method(edited_control, "add_theme_color_override", "font_outline_color", p_color);
+ if (edited_control->has_theme_color_override("font_outline_color")) {
+ ur->add_undo_method(edited_control, "add_theme_color_override", "font_outline_color", edited_control->get_theme_color("font_outline_color"));
+ } else {
+ ur->add_undo_method(edited_control, "remove_theme_color_override", "font_outline_color");
}
+
+ ur->add_do_method(this, "_update_control");
+ ur->add_undo_method(this, "_update_control");
+
+ ur->commit_action();
}
void TextControlEditor::_clear_formatting() {
- if (edited_control) {
- edited_control->begin_bulk_theme_override();
- edited_control->remove_theme_font_override(edited_font);
- edited_control->remove_theme_font_size_override(edited_font_size);
- edited_control->remove_theme_color_override(edited_color);
- edited_control->remove_theme_color_override("font_outline_color");
- edited_control->remove_theme_constant_override("outline_size");
- edited_control->end_bulk_theme_override();
- _update_control();
+ if (!edited_control) {
+ return;
+ }
+
+ UndoRedo *ur = EditorNode::get_singleton()->get_undo_redo();
+ ur->create_action(TTR("Clear Control Formatting"));
+
+ ur->add_do_method(edited_control, "begin_bulk_theme_override");
+ ur->add_undo_method(edited_control, "begin_bulk_theme_override");
+
+ ur->add_do_method(edited_control, "remove_theme_font_override", edited_font);
+ if (edited_control->has_theme_font_override(edited_font)) {
+ ur->add_undo_method(edited_control, "add_theme_font_override", edited_font, edited_control->get_theme_font(edited_font));
+ }
+
+ ur->add_do_method(edited_control, "remove_theme_font_size_override", edited_font_size);
+ if (edited_control->has_theme_font_size_override(edited_font_size)) {
+ ur->add_undo_method(edited_control, "add_theme_font_size_override", edited_font_size, edited_control->get_theme_font_size(edited_font_size));
+ }
+
+ ur->add_do_method(edited_control, "remove_theme_color_override", edited_color);
+ if (edited_control->has_theme_color_override(edited_color)) {
+ ur->add_undo_method(edited_control, "add_theme_color_override", edited_color, edited_control->get_theme_color(edited_color));
+ }
+
+ ur->add_do_method(edited_control, "remove_theme_color_override", "font_outline_color");
+ if (edited_control->has_theme_color_override("font_outline_color")) {
+ ur->add_undo_method(edited_control, "add_theme_color_override", "font_outline_color", edited_control->get_theme_color("font_outline_color"));
+ }
+
+ ur->add_do_method(edited_control, "remove_theme_constant_override", "outline_size");
+ if (edited_control->has_theme_constant_override("outline_size")) {
+ ur->add_undo_method(edited_control, "add_theme_constant_override", "outline_size", edited_control->get_theme_constant("outline_size"));
}
+
+ ur->add_do_method(edited_control, "end_bulk_theme_override");
+ ur->add_undo_method(edited_control, "end_bulk_theme_override");
+
+ ur->add_do_method(this, "_update_control");
+ ur->add_undo_method(this, "_update_control");
+
+ ur->commit_action();
}
void TextControlEditor::edit(Object *p_object) {
diff --git a/editor/plugins/text_control_editor_plugin.h b/editor/plugins/text_control_editor_plugin.h
index d3a4ff5ef9..d284a30f16 100644
--- a/editor/plugins/text_control_editor_plugin.h
+++ b/editor/plugins/text_control_editor_plugin.h
@@ -70,7 +70,7 @@ class TextControlEditor : public HBoxContainer {
protected:
void _notification(int p_notification);
- static void _bind_methods(){};
+ static void _bind_methods();
void _find_resources(EditorFileSystemDirectory *p_dir);
void _reload_fonts(const String &p_path);
diff --git a/scene/gui/graph_edit.cpp b/scene/gui/graph_edit.cpp
index 92c770429b..3701a8139b 100644
--- a/scene/gui/graph_edit.cpp
+++ b/scene/gui/graph_edit.cpp
@@ -773,8 +773,9 @@ bool GraphEdit::_check_clickable_control(Control *p_control, const Vector2 &pos)
}
bool GraphEdit::is_in_input_hotzone(GraphNode *p_graph_node, int p_slot_index, const Vector2 &p_mouse_pos, const Vector2i &p_port_size) {
- if (get_script_instance() && get_script_instance()->has_method("_is_in_input_hotzone")) {
- return get_script_instance()->call("_is_in_input_hotzone", p_graph_node, p_slot_index, p_mouse_pos);
+ bool success;
+ if (GDVIRTUAL_CALL(_is_in_input_hotzone, p_graph_node, p_slot_index, p_mouse_pos, success)) {
+ return success;
} else {
Vector2 pos = p_graph_node->get_connection_input_position(p_slot_index) + p_graph_node->get_position();
return is_in_port_hotzone(pos / zoom, p_mouse_pos, p_port_size, true);
@@ -782,8 +783,9 @@ bool GraphEdit::is_in_input_hotzone(GraphNode *p_graph_node, int p_slot_index, c
}
bool GraphEdit::is_in_output_hotzone(GraphNode *p_graph_node, int p_slot_index, const Vector2 &p_mouse_pos, const Vector2i &p_port_size) {
- if (get_script_instance() && get_script_instance()->has_method("_is_in_output_hotzone")) {
- return get_script_instance()->call("_is_in_output_hotzone", p_graph_node, p_slot_index, p_mouse_pos);
+ bool success;
+ if (GDVIRTUAL_CALL(_is_in_output_hotzone, p_graph_node, p_slot_index, p_mouse_pos, success)) {
+ return success;
} else {
Vector2 pos = p_graph_node->get_connection_output_position(p_slot_index) + p_graph_node->get_position();
return is_in_port_hotzone(pos / zoom, p_mouse_pos, p_port_size, false);
@@ -2227,8 +2229,8 @@ void GraphEdit::_bind_methods() {
ClassDB::bind_method(D_METHOD("is_right_disconnects_enabled"), &GraphEdit::is_right_disconnects_enabled);
ClassDB::bind_method(D_METHOD("_update_scroll_offset"), &GraphEdit::_update_scroll_offset);
- ClassDB::add_virtual_method(get_class_static(), MethodInfo(Variant::BOOL, "_is_in_input_hotzone", PropertyInfo(Variant::OBJECT, "graph_node"), PropertyInfo(Variant::INT, "slot_index"), PropertyInfo(Variant::VECTOR2, "mouse_position")));
- ClassDB::add_virtual_method(get_class_static(), MethodInfo(Variant::BOOL, "_is_in_output_hotzone", PropertyInfo(Variant::OBJECT, "graph_node"), PropertyInfo(Variant::INT, "slot_index"), PropertyInfo(Variant::VECTOR2, "mouse_position")));
+ GDVIRTUAL_BIND(_is_in_input_hotzone, "graph_node", "slot_index", "mouse_position");
+ GDVIRTUAL_BIND(_is_in_output_hotzone, "graph_node", "slot_index", "mouse_position");
ClassDB::bind_method(D_METHOD("get_zoom_hbox"), &GraphEdit::get_zoom_hbox);
diff --git a/scene/gui/graph_edit.h b/scene/gui/graph_edit.h
index f1c4e95e38..145e0dcc59 100644
--- a/scene/gui/graph_edit.h
+++ b/scene/gui/graph_edit.h
@@ -261,6 +261,8 @@ protected:
void _notification(int p_what);
GDVIRTUAL2RC(Vector<Vector2>, _get_connection_line, Vector2, Vector2)
+ GDVIRTUAL3R(bool, _is_in_input_hotzone, Object *, int, Vector2)
+ GDVIRTUAL3R(bool, _is_in_output_hotzone, Object *, int, Vector2)
public:
Error connect_node(const StringName &p_from, int p_from_port, const StringName &p_to, int p_to_port);
diff --git a/scene/gui/rich_text_label.cpp b/scene/gui/rich_text_label.cpp
index fe25d027f6..348a0324f4 100644
--- a/scene/gui/rich_text_label.cpp
+++ b/scene/gui/rich_text_label.cpp
@@ -2363,6 +2363,7 @@ void RichTextLabel::_remove_item(Item *p_item, const int p_line, const int p_sub
// Then remove the provided item itself.
p_item->parent->subitems.erase(p_item);
}
+ memdelete(p_item);
}
void RichTextLabel::add_image(const Ref<Texture2D> &p_image, const int p_width, const int p_height, const Color &p_color, InlineAlignment p_alignment) {
diff --git a/scene/main/viewport.cpp b/scene/main/viewport.cpp
index 3e63ba7869..abbd7ba5a0 100644
--- a/scene/main/viewport.cpp
+++ b/scene/main/viewport.cpp
@@ -372,8 +372,6 @@ void Viewport::_sub_window_remove(Window *p_window) {
void Viewport::_notification(int p_what) {
switch (p_what) {
case NOTIFICATION_ENTER_TREE: {
- gui.embedding_subwindows = gui.embed_subwindows_hint;
-
if (get_parent()) {
parent = get_parent()->get_viewport();
RenderingServer::get_singleton()->viewport_set_parent_viewport(viewport, parent->get_viewport_rid());
@@ -2546,7 +2544,7 @@ bool Viewport::_sub_windows_forward_input(const Ref<InputEvent> &p_event) {
if (mb.is_valid() && mb->is_pressed() && mb->get_button_index() == MouseButton::LEFT) {
bool click_on_window = false;
for (int i = gui.sub_windows.size() - 1; i >= 0; i--) {
- SubWindow &sw = gui.sub_windows.write[i];
+ SubWindow sw = gui.sub_windows.write[i];
// Clicked inside window?
diff --git a/scene/main/viewport.h b/scene/main/viewport.h
index 57e1100521..a3127811f5 100644
--- a/scene/main/viewport.h
+++ b/scene/main/viewport.h
@@ -362,7 +362,6 @@ private:
bool dragging = false;
bool drag_successful = false;
bool embed_subwindows_hint = false;
- bool embedding_subwindows = false;
Window *subwindow_focused = nullptr;
SubWindowDrag subwindow_drag = SUB_WINDOW_DRAG_DISABLED;
@@ -373,7 +372,7 @@ private:
SubWindowResize subwindow_resize_mode;
Rect2i subwindow_resize_from_rect;
- Vector<SubWindow> sub_windows;
+ Vector<SubWindow> sub_windows; // Don't obtain references or pointers to the elements, as their location can change.
} gui;
DefaultCanvasItemTextureFilter default_canvas_item_texture_filter = DEFAULT_CANVAS_ITEM_TEXTURE_FILTER_LINEAR;