diff options
31 files changed, 168 insertions, 86 deletions
diff --git a/core/object.cpp b/core/object.cpp index 5e6c809f7a..cd084a0c4a 100644 --- a/core/object.cpp +++ b/core/object.cpp @@ -1472,7 +1472,7 @@ Error Object::connect(const StringName &p_signal, Object *p_to_object, const Str Signal::Target target(p_to_object->get_instance_id(), p_to_method); if (s->slot_map.has(target)) { - ERR_EXPLAIN("Signal '" + p_signal + "'' already connected to given method '" + p_to_method + "' in that object."); + ERR_EXPLAIN("Signal '" + p_signal + "' is already connected to given method '" + p_to_method + "' in that object."); ERR_FAIL_COND_V(s->slot_map.has(target), ERR_INVALID_PARAMETER); } diff --git a/core/object.h b/core/object.h index 88229d27b6..746450ef6a 100644 --- a/core/object.h +++ b/core/object.h @@ -185,6 +185,7 @@ struct MethodInfo { uint32_t flags; int id; + inline bool operator==(const MethodInfo &p_method) const { return id == p_method.id; } inline bool operator<(const MethodInfo &p_method) const { return id == p_method.id ? (name < p_method.name) : (id < p_method.id); } operator Dictionary() const; @@ -571,8 +572,8 @@ public: #else if (!p_object) return NULL; - if (p_pobject->is_class_ptr(T::get_class_ptr_static())) - return static_cast<T *>(p_pobject); + if (p_object->is_class_ptr(T::get_class_ptr_static())) + return static_cast<T *>(p_object); else return NULL; #endif @@ -591,7 +592,7 @@ public: #else if (!p_object) return NULL; - if (p_pobject->is_class_ptr(T::get_class_ptr_static())) + if (p_object->is_class_ptr(T::get_class_ptr_static())) return static_cast<const T *>(p_object); else return NULL; diff --git a/drivers/gles3/rasterizer_gles3.cpp b/drivers/gles3/rasterizer_gles3.cpp index e025992c0b..274782c997 100644 --- a/drivers/gles3/rasterizer_gles3.cpp +++ b/drivers/gles3/rasterizer_gles3.cpp @@ -247,11 +247,8 @@ void RasterizerGLES3::set_current_render_target(RID p_render_target) { if (p_render_target.is_valid()) { RasterizerStorageGLES3::RenderTarget *rt = storage->render_target_owner.getornull(p_render_target); - if (!rt) { - storage->frame.current_rt = NULL; - } - ERR_FAIL_COND(!rt); storage->frame.current_rt = rt; + ERR_FAIL_COND(!rt); storage->frame.clear_request = false; glViewport(0, 0, rt->width, rt->height); diff --git a/editor/animation_editor.cpp b/editor/animation_editor.cpp index 55542a59a2..5b24baabea 100644 --- a/editor/animation_editor.cpp +++ b/editor/animation_editor.cpp @@ -1646,7 +1646,7 @@ PropertyInfo AnimationKeyEditor::_find_hint_for_track(int p_idx, NodePath &r_bas List<PropertyInfo> pinfo; if (res.is_valid()) res->get_property_list(&pinfo); - else + else if (node) node->get_property_list(&pinfo); for (List<PropertyInfo>::Element *E = pinfo.front(); E; E = E->next()) { diff --git a/editor/editor_help.cpp b/editor/editor_help.cpp index 86f31d7589..17105606df 100644 --- a/editor/editor_help.cpp +++ b/editor/editor_help.cpp @@ -294,7 +294,6 @@ EditorHelpSearch::EditorHelpSearch() { VBoxContainer *vbc = memnew(VBoxContainer); add_child(vbc); - HBoxContainer *sb_hb = memnew(HBoxContainer); search_box = memnew(LineEdit); vbc->add_child(search_box); search_box->connect("text_changed", this, "_text_changed"); @@ -893,6 +892,8 @@ Error EditorHelp::_goto_desc(const String &p_class, int p_vscr) { for (int i = 0; i < methods.size(); i++) { + bool is_vararg = methods[i].qualifiers.find("vararg") != -1; + class_desc->push_cell(); method_line[methods[i].name] = class_desc->get_line_count() - 2; //gets overridden if description @@ -916,7 +917,7 @@ Error EditorHelp::_goto_desc(const String &p_class, int p_vscr) { if (methods[i].description != "") class_desc->pop(); class_desc->push_color(EditorSettings::get_singleton()->get("text_editor/highlighting/symbol_color")); - class_desc->add_text(methods[i].arguments.size() ? "( " : "("); + class_desc->add_text(methods[i].arguments.size() || is_vararg ? "( " : "("); class_desc->pop(); for (int j = 0; j < methods[i].arguments.size(); j++) { class_desc->push_color(EditorSettings::get_singleton()->get("text_editor/highlighting/text_color")); @@ -936,17 +937,18 @@ Error EditorHelp::_goto_desc(const String &p_class, int p_vscr) { class_desc->pop(); } - if (methods[i].qualifiers.find("vararg") != -1) { + if (is_vararg) { class_desc->push_color(EditorSettings::get_singleton()->get("text_editor/highlighting/text_color")); - class_desc->add_text(","); + if (methods[i].arguments.size()) + class_desc->add_text(", "); class_desc->push_color(EditorSettings::get_singleton()->get("text_editor/highlighting/symbol_color")); - class_desc->add_text(" ... "); + class_desc->add_text("..."); class_desc->pop(); class_desc->pop(); } class_desc->push_color(EditorSettings::get_singleton()->get("text_editor/highlighting/symbol_color")); - class_desc->add_text(methods[i].arguments.size() ? " )" : ")"); + class_desc->add_text(methods[i].arguments.size() || is_vararg ? " )" : ")"); class_desc->pop(); if (methods[i].qualifiers != "") { @@ -1313,6 +1315,8 @@ Error EditorHelp::_goto_desc(const String &p_class, int p_vscr) { for (int i = 0; i < methods.size(); i++) { + bool is_vararg = methods[i].qualifiers.find("vararg") != -1; + method_line[methods[i].name] = class_desc->get_line_count() - 2; class_desc->push_font(doc_code_font); @@ -1323,7 +1327,7 @@ Error EditorHelp::_goto_desc(const String &p_class, int p_vscr) { _add_text(methods[i].name); class_desc->pop(); class_desc->push_color(EditorSettings::get_singleton()->get("text_editor/highlighting/symbol_color")); - class_desc->add_text(methods[i].arguments.size() ? "( " : "("); + class_desc->add_text(methods[i].arguments.size() || is_vararg ? "( " : "("); class_desc->pop(); for (int j = 0; j < methods[i].arguments.size(); j++) { class_desc->push_color(EditorSettings::get_singleton()->get("text_editor/highlighting/text_color")); @@ -1343,8 +1347,18 @@ Error EditorHelp::_goto_desc(const String &p_class, int p_vscr) { class_desc->pop(); } + if (is_vararg) { + class_desc->push_color(EditorSettings::get_singleton()->get("text_editor/highlighting/text_color")); + if (methods[i].arguments.size()) + class_desc->add_text(", "); + class_desc->push_color(EditorSettings::get_singleton()->get("text_editor/highlighting/symbol_color")); + class_desc->add_text("..."); + class_desc->pop(); + class_desc->pop(); + } + class_desc->push_color(EditorSettings::get_singleton()->get("text_editor/highlighting/symbol_color")); - class_desc->add_text(methods[i].arguments.size() ? " )" : ")"); + class_desc->add_text(methods[i].arguments.size() || is_vararg ? " )" : ")"); class_desc->pop(); if (methods[i].qualifiers != "") { diff --git a/editor/editor_node.cpp b/editor/editor_node.cpp index c07055114d..06e9860552 100644 --- a/editor/editor_node.cpp +++ b/editor/editor_node.cpp @@ -2218,16 +2218,21 @@ void EditorNode::_menu_option_confirm(int p_option, bool p_confirmed) { update_menu->get_popup()->set_item_checked(0, true); update_menu->get_popup()->set_item_checked(1, false); OS::get_singleton()->set_low_processor_usage_mode(false); + EditorSettings::get_singleton()->set_project_metadata("editor_options", "update_mode", SETTINGS_UPDATE_ALWAYS); } break; case SETTINGS_UPDATE_CHANGES: { update_menu->get_popup()->set_item_checked(0, false); update_menu->get_popup()->set_item_checked(1, true); OS::get_singleton()->set_low_processor_usage_mode(true); + EditorSettings::get_singleton()->set_project_metadata("editor_options", "update_mode", SETTINGS_UPDATE_CHANGES); } break; case SETTINGS_UPDATE_SPINNER_HIDE: { + update_menu->set_icon(gui_base->get_icon("Collapse", "EditorIcons")); update_menu->get_popup()->toggle_item_checked(3); + bool checked = update_menu->get_popup()->is_item_checked(3); + EditorSettings::get_singleton()->set_project_metadata("editor_options", "update_spinner_hide", checked); } break; case SETTINGS_PREFERENCES: { @@ -4980,7 +4985,12 @@ EditorNode::EditorNode() { p->add_check_item(TTR("Update Changes"), SETTINGS_UPDATE_CHANGES); p->add_separator(); p->add_check_item(TTR("Disable Update Spinner"), SETTINGS_UPDATE_SPINNER_HIDE); - p->set_item_checked(1, true); + int update_mode = EditorSettings::get_singleton()->get_project_metadata("editor_options", "update_mode", SETTINGS_UPDATE_CHANGES); + int hide_spinner = EditorSettings::get_singleton()->get_project_metadata("editor_options", "update_spinner_hide", false); + _menu_option(update_mode); + if (hide_spinner) { + _menu_option(SETTINGS_UPDATE_SPINNER_HIDE); + } scene_tree_dock = memnew(SceneTreeDock(this, scene_root, editor_selection, editor_data)); scene_tree_dock->set_name(TTR("Scene")); @@ -5367,7 +5377,6 @@ EditorNode::EditorNode() { save_external_resources_mem = true; set_process(true); - OS::get_singleton()->set_low_processor_usage_mode(true); open_imported = memnew(ConfirmationDialog); open_imported->get_ok()->set_text(TTR("Open Anyway")); @@ -5475,6 +5484,7 @@ EditorNode::~EditorNode() { memdelete(editor_plugins_over); memdelete(editor_plugins_force_input_forwarding); memdelete(file_server); + memdelete(progress_hb); EditorSettings::destroy(); } diff --git a/editor/editor_settings.cpp b/editor/editor_settings.cpp index 5b73d83691..c30ffd4b4e 100644 --- a/editor/editor_settings.cpp +++ b/editor/editor_settings.cpp @@ -253,13 +253,14 @@ static void _create_script_templates(const String &p_path) { dir->change_dir(p_path); for (int i = 0; i < keys.size(); i++) { if (!dir->file_exists(keys[i])) { - file->reopen(p_path.plus_file((String)keys[i]), FileAccess::WRITE); - ERR_FAIL_COND(!file); + Error err = file->reopen(p_path.plus_file((String)keys[i]), FileAccess::WRITE); + ERR_FAIL_COND(err != OK); file->store_string(templates[keys[i]]); file->close(); } } + memdelete(dir); memdelete(file); } @@ -286,6 +287,7 @@ void EditorSettings::create() { self_contained = true; extra_config->load(exe_path + "/_sc_"); } + memdelete(d); if (self_contained) { // editor is self contained diff --git a/editor/plugins/canvas_item_editor_plugin.cpp b/editor/plugins/canvas_item_editor_plugin.cpp index 0dcabb1776..701952d249 100644 --- a/editor/plugins/canvas_item_editor_plugin.cpp +++ b/editor/plugins/canvas_item_editor_plugin.cpp @@ -3766,7 +3766,7 @@ bool CanvasItemEditorViewport::_cyclical_dependency_exists(const String &p_targe void CanvasItemEditorViewport::_create_nodes(Node *parent, Node *child, String &path, const Point2 &p_point) { child->set_name(path.get_file().get_basename()); - Ref<Texture> texture = Object::cast_to<Texture>(Ref<Texture>(ResourceCache::get(path)).ptr()); + Ref<Texture> texture = Ref<Texture>(Object::cast_to<Texture>(ResourceCache::get(path))); Size2 texture_size = texture->get_size(); editor_data->get_undo_redo().add_do_method(parent, "add_child", child); @@ -4102,3 +4102,7 @@ CanvasItemEditorViewport::CanvasItemEditorViewport(EditorNode *p_node, CanvasIte label_desc->hide(); editor->get_gui_base()->add_child(label_desc); } + +CanvasItemEditorViewport::~CanvasItemEditorViewport() { + memdelete(preview); +} diff --git a/editor/plugins/canvas_item_editor_plugin.h b/editor/plugins/canvas_item_editor_plugin.h index 9b027fda60..0291660d42 100644 --- a/editor/plugins/canvas_item_editor_plugin.h +++ b/editor/plugins/canvas_item_editor_plugin.h @@ -512,6 +512,7 @@ public: virtual void drop_data(const Point2 &p_point, const Variant &p_data); CanvasItemEditorViewport(EditorNode *p_node, CanvasItemEditor *p_canvas); + ~CanvasItemEditorViewport(); }; #endif diff --git a/editor/plugins/collision_polygon_editor_plugin.cpp b/editor/plugins/collision_polygon_editor_plugin.cpp index 5520d196e0..c6fa796226 100644 --- a/editor/plugins/collision_polygon_editor_plugin.cpp +++ b/editor/plugins/collision_polygon_editor_plugin.cpp @@ -48,6 +48,9 @@ void CollisionPolygonEditor::_notification(int p_what) { } break; case NOTIFICATION_PROCESS: { + if (!node) { + return; + } if (node->get_depth() != prev_depth) { _polygon_draw(); diff --git a/editor/project_manager.cpp b/editor/project_manager.cpp index 0d57fe05b9..9cb110a2ca 100644 --- a/editor/project_manager.cpp +++ b/editor/project_manager.cpp @@ -805,7 +805,8 @@ void ProjectManager::_load_recent_projects() { Error err = img->load(appicon.replace_first("res://", path + "/")); if (err == OK) { - img->resize(64, 64); + Ref<Texture> default_icon = get_icon("DefaultProjectIcon", "EditorIcons"); + img->resize(default_icon->get_width(), default_icon->get_height()); Ref<ImageTexture> it = memnew(ImageTexture); it->create_from_image(img); icon = it; diff --git a/editor/script_create_dialog.cpp b/editor/script_create_dialog.cpp index 299538a2b3..b70c63c97c 100644 --- a/editor/script_create_dialog.cpp +++ b/editor/script_create_dialog.cpp @@ -591,6 +591,9 @@ ScriptCreateDialog::ScriptCreateDialog() { hb->add_child(vb); hb->add_child(empty_v->duplicate()); + memdelete(empty_h); + memdelete(empty_v); + add_child(hb); /* Language */ diff --git a/editor/script_editor_debugger.cpp b/editor/script_editor_debugger.cpp index 689bea2749..d1d9f86b66 100644 --- a/editor/script_editor_debugger.cpp +++ b/editor/script_editor_debugger.cpp @@ -789,14 +789,17 @@ void ScriptEditorDebugger::_performance_draw() { which.push_back(i); } - if (which.empty()) + Ref<Font> graph_font = get_font("font", "TextEdit"); + + if (which.empty()) { + perf_draw->draw_string(graph_font, Point2(0, graph_font->get_ascent()), TTR("Pick one or more items from the list to display the graph."), get_color("font_color", "Label"), perf_draw->get_size().x); return; + } Ref<StyleBox> graph_sb = get_stylebox("normal", "TextEdit"); - Ref<Font> graph_font = get_font("font", "TextEdit"); int cols = Math::ceil(Math::sqrt((float)which.size())); - int rows = (which.size() + 1) / cols; + int rows = Math::ceil((float)which.size() / cols); if (which.size() == 1) rows = 1; diff --git a/modules/gdscript/gd_editor.cpp b/modules/gdscript/gd_editor.cpp index d06da08551..905c784ab9 100644 --- a/modules/gdscript/gd_editor.cpp +++ b/modules/gdscript/gd_editor.cpp @@ -1546,7 +1546,9 @@ static void _find_type_arguments(GDCompletionContext &context, const GDParser::N scr = NULL; } } else { - on_script = obj->get_script(); + if (obj) { + on_script = obj->get_script(); + } } } @@ -2237,7 +2239,9 @@ Error GDScriptLanguage::complete_code(const String &p_code, const String &p_base scr = NULL; } } else { - on_script = obj->get_script(); + if (obj) { + on_script = obj->get_script(); + } } } diff --git a/modules/gridmap/grid_map_editor_plugin.cpp b/modules/gridmap/grid_map_editor_plugin.cpp index 561efb9d0f..3bab1bfbc1 100644 --- a/modules/gridmap/grid_map_editor_plugin.cpp +++ b/modules/gridmap/grid_map_editor_plugin.cpp @@ -835,6 +835,9 @@ void GridMapEditor::_notification(int p_what) { duplicate_instance = RID(); } else if (p_what == NOTIFICATION_PROCESS) { + if (!node) { + return; + } Transform xf = node->get_global_transform(); diff --git a/modules/visual_script/visual_script_func_nodes.cpp b/modules/visual_script/visual_script_func_nodes.cpp index 32f5945a10..b51ef6beef 100644 --- a/modules/visual_script/visual_script_func_nodes.cpp +++ b/modules/visual_script/visual_script_func_nodes.cpp @@ -822,7 +822,7 @@ public: } Node *another = node->get_node(node_path); - if (!node) { + if (!another) { r_error.error = Variant::CallError::CALL_ERROR_INVALID_METHOD; r_error_str = "Path does not lead Node!"; return 0; @@ -1596,7 +1596,7 @@ public: } Node *another = node->get_node(node_path); - if (!node) { + if (!another) { r_error.error = Variant::CallError::CALL_ERROR_INVALID_METHOD; r_error_str = "Path does not lead Node!"; return 0; @@ -2241,7 +2241,7 @@ public: } Node *another = node->get_node(node_path); - if (!node) { + if (!another) { r_error.error = Variant::CallError::CALL_ERROR_INVALID_METHOD; r_error_str = RTR("Path does not lead Node!"); return 0; diff --git a/modules/visual_script/visual_script_nodes.cpp b/modules/visual_script/visual_script_nodes.cpp index 0d65638bb9..5e74c970e3 100644 --- a/modules/visual_script/visual_script_nodes.cpp +++ b/modules/visual_script/visual_script_nodes.cpp @@ -2087,7 +2087,7 @@ public: } Node *another = node->get_node(path); - if (!node) { + if (!another) { r_error.error = Variant::CallError::CALL_ERROR_INVALID_METHOD; r_error_str = "Path does not lead Node!"; return 0; diff --git a/modules/visual_script/visual_script_yield_nodes.cpp b/modules/visual_script/visual_script_yield_nodes.cpp index 958eacf2f2..08adc13193 100644 --- a/modules/visual_script/visual_script_yield_nodes.cpp +++ b/modules/visual_script/visual_script_yield_nodes.cpp @@ -535,7 +535,7 @@ public: } Node *another = node->get_node(node_path); - if (!node) { + if (!another) { r_error.error = Variant::CallError::CALL_ERROR_INVALID_METHOD; r_error_str = "Path does not lead Node!"; return 0; diff --git a/platform/android/java_class_wrapper.cpp b/platform/android/java_class_wrapper.cpp index 5693195bfa..ffd9150ba4 100644 --- a/platform/android/java_class_wrapper.cpp +++ b/platform/android/java_class_wrapper.cpp @@ -112,7 +112,7 @@ bool JavaClass::_call_method(JavaObject *p_instance, const StringName &p_method, Ref<Reference> ref = *p_args[i]; if (!ref.is_null()) { - if (Object::cast_to<JavaObject>(ref)) { + if (Object::cast_to<JavaObject>(ref.ptr())) { Ref<JavaObject> jo = ref; //could be faster diff --git a/platform/windows/godot_win.cpp b/platform/windows/godot_win.cpp index df2d96e516..6f1fb04706 100644 --- a/platform/windows/godot_win.cpp +++ b/platform/windows/godot_win.cpp @@ -136,8 +136,13 @@ int widechar_main(int argc, wchar_t **argv) { Error err = Main::setup(argv_utf8[0], argc - 1, &argv_utf8[1]); - if (err != OK) + if (err != OK) { + for (int i = 0; i < argc; ++i) { + delete[] argv_utf8[i]; + } + delete[] argv_utf8; return 255; + } if (Main::start()) os.run(); diff --git a/platform/x11/godot_x11.cpp b/platform/x11/godot_x11.cpp index 6f418b213f..f02f3cb881 100644 --- a/platform/x11/godot_x11.cpp +++ b/platform/x11/godot_x11.cpp @@ -45,8 +45,10 @@ int main(int argc, char *argv[]) { getcwd(cwd, PATH_MAX); Error err = Main::setup(argv[0], argc - 1, &argv[1]); - if (err != OK) + if (err != OK) { + free(cwd); return 255; + } if (Main::start()) os.run(); // it is actually the OS that decides how to run diff --git a/platform/x11/os_x11.cpp b/platform/x11/os_x11.cpp index dbc3914410..8332b2f51c 100644 --- a/platform/x11/os_x11.cpp +++ b/platform/x11/os_x11.cpp @@ -116,24 +116,22 @@ void OS_X11::initialize(const VideoMode &p_desired, int p_video_driver, int p_au /** XLIB INITIALIZATION **/ x11_display = XOpenDisplay(NULL); + char *modifiers = NULL; Bool xkb_dar = False; if (x11_display) { XAutoRepeatOn(x11_display); xkb_dar = XkbSetDetectableAutoRepeat(x11_display, True, NULL); - } - - char *modifiers = NULL; - - // Try to support IME if detectable auto-repeat is supported - if (xkb_dar == True) { + // Try to support IME if detectable auto-repeat is supported + if (xkb_dar == True) { // Xutf8LookupString will be used later instead of XmbLookupString before // the multibyte sequences can be converted to unicode string. #ifdef X_HAVE_UTF8_STRING - modifiers = XSetLocaleModifiers(""); + modifiers = XSetLocaleModifiers(""); #endif + } } if (modifiers == NULL) { @@ -141,8 +139,6 @@ void OS_X11::initialize(const VideoMode &p_desired, int p_video_driver, int p_au WARN_PRINT("IME is disabled"); } modifiers = XSetLocaleModifiers("@im=none"); - } - if (modifiers == NULL) { WARN_PRINT("Error setting locale modifiers"); } @@ -538,6 +534,8 @@ void OS_X11::finalize() { physics_2d_server->finish(); memdelete(physics_2d_server); + memdelete(power_manager); + if (xrandr_handle) dlclose(xrandr_handle); diff --git a/platform/x11/power_x11.cpp b/platform/x11/power_x11.cpp index 8e69a2223f..72fa5cf380 100644 --- a/platform/x11/power_x11.cpp +++ b/platform/x11/power_x11.cpp @@ -58,6 +58,7 @@ Adapted from corresponding SDL 2.0 code. #include <stdio.h> #include <unistd.h> +#include "core/error_macros.h" #include <dirent.h> #include <fcntl.h> #include <sys/stat.h> @@ -254,9 +255,9 @@ bool PowerX11::GetPowerInfo_Linux_proc_acpi() { this->power_state = POWERSTATE_UNKNOWN; dirp->change_dir(proc_acpi_battery_path); - dirp->list_dir_begin(); + Error err = dirp->list_dir_begin(); - if (dirp == NULL) { + if (err != OK) { return false; /* can't use this interface. */ } else { node = dirp->get_next(); @@ -268,8 +269,8 @@ bool PowerX11::GetPowerInfo_Linux_proc_acpi() { } dirp->change_dir(proc_acpi_ac_adapter_path); - dirp->list_dir_begin(); - if (dirp == NULL) { + err = dirp->list_dir_begin(); + if (err != OK) { return false; /* can't use this interface. */ } else { node = dirp->get_next(); @@ -438,9 +439,9 @@ bool PowerX11::GetPowerInfo_Linux_sys_class_power_supply(/*PowerState *state, in DirAccess *dirp = DirAccess::create(DirAccess::ACCESS_FILESYSTEM); dirp->change_dir(base); - dirp->list_dir_begin(); + Error err = dirp->list_dir_begin(); - if (!dirp) { + if (err != OK) { return false; } diff --git a/scene/gui/text_edit.cpp b/scene/gui/text_edit.cpp index 2c50b4e854..d585562dc6 100644 --- a/scene/gui/text_edit.cpp +++ b/scene/gui/text_edit.cpp @@ -215,8 +215,8 @@ void TextEdit::Text::_update_line_cache(int p_line) const { const Map<int, TextEdit::Text::ColorRegionInfo> &TextEdit::Text::get_color_region_info(int p_line) { - Map<int, ColorRegionInfo> *cri = NULL; - ERR_FAIL_INDEX_V(p_line, text.size(), *cri); //enjoy your crash + static Map<int, ColorRegionInfo> cri; + ERR_FAIL_INDEX_V(p_line, text.size(), cri); if (text[p_line].width_cache == -1) { _update_line_cache(p_line); @@ -2115,14 +2115,14 @@ void TextEdit::_gui_input(const Ref<InputEvent> &p_gui_input) { //keep indentation int space_count = 0; for (int i = 0; i < text[cursor.line].length(); i++) { - if (text[cursor.line][i] == '\t') { + if (text[cursor.line][i] == '\t' && cursor.column > 0) { if (indent_using_spaces) { ins += space_indent; } else { ins += "\t"; } space_count = 0; - } else if (text[cursor.line][i] == ' ') { + } else if (text[cursor.line][i] == ' ' && cursor.column > 0) { space_count++; if (space_count == indent_size) { @@ -2736,6 +2736,15 @@ void TextEdit::_gui_input(const Ref<InputEvent> &p_gui_input) { else undo(); } break; + case KEY_Y: { + + if (!k->get_command()) { + scancode_handled = false; + break; + } + + redo(); + } break; case KEY_V: { if (readonly) { break; diff --git a/scene/gui/tree.cpp b/scene/gui/tree.cpp index 20bf818d44..a40d1acb8f 100644 --- a/scene/gui/tree.cpp +++ b/scene/gui/tree.cpp @@ -2473,22 +2473,24 @@ void Tree::_gui_input(Ref<InputEvent> p_event) { Point2 pos = b->get_position() - bg->get_offset(); cache.click_type = Cache::CLICK_NONE; - if (show_column_titles && b->get_button_index() == BUTTON_LEFT) { + if (show_column_titles) { pos.y -= _get_title_button_height(); if (pos.y < 0) { - pos.x += cache.offset.x; - int len = 0; - for (int i = 0; i < columns.size(); i++) { - - len += get_column_width(i); - if (pos.x < len) { - - cache.click_type = Cache::CLICK_TITLE; - cache.click_index = i; - //cache.click_id=; - update(); - break; + if (b->get_button_index() == BUTTON_LEFT) { + pos.x += cache.offset.x; + int len = 0; + for (int i = 0; i < columns.size(); i++) { + + len += get_column_width(i); + if (pos.x < len) { + + cache.click_type = Cache::CLICK_TITLE; + cache.click_index = i; + //cache.click_id=; + update(); + break; + } } } break; @@ -2868,8 +2870,8 @@ TreeItem *Tree::create_item(TreeItem *p_parent) { TreeItem *ti = memnew(TreeItem(this)); - ti->cells.resize(columns.size()); ERR_FAIL_COND_V(!ti, NULL); + ti->cells.resize(columns.size()); if (p_parent) { diff --git a/scene/main/scene_tree.cpp b/scene/main/scene_tree.cpp index 03a604734e..99af8face0 100644 --- a/scene/main/scene_tree.cpp +++ b/scene/main/scene_tree.cpp @@ -1401,8 +1401,11 @@ void SceneTree::_live_edit_create_node_func(const NodePath &p_parent, const Stri Node *n2 = n->get_node(p_parent); Node *no = Object::cast_to<Node>(ClassDB::instance(p_type)); - no->set_name(p_name); + if (!no) { + continue; + } + no->set_name(p_name); n2->add_child(no); } } @@ -1705,6 +1708,11 @@ Vector<int> SceneTree::get_network_connected_peers() const { return ret; } + +int SceneTree::get_rpc_sender_id() const { + return rpc_sender_id; +} + void SceneTree::set_refuse_new_network_connections(bool p_refuse) { ERR_FAIL_COND(!network_peer.is_valid()); network_peer->set_refuse_new_connections(p_refuse); @@ -2099,7 +2107,9 @@ void SceneTree::_network_poll() { ERR_PRINT("Error getting packet!"); } + rpc_sender_id = sender; _network_process_packet(sender, packet, len); + rpc_sender_id = 0; if (!network_peer.is_valid()) { break; //it's also possible that a packet or RPC caused a disconnection, so also check here @@ -2179,6 +2189,7 @@ void SceneTree::_bind_methods() { ClassDB::bind_method(D_METHOD("has_network_peer"), &SceneTree::has_network_peer); ClassDB::bind_method(D_METHOD("get_network_connected_peers"), &SceneTree::get_network_connected_peers); ClassDB::bind_method(D_METHOD("get_network_unique_id"), &SceneTree::get_network_unique_id); + ClassDB::bind_method(D_METHOD("get_rpc_sender_id"), &SceneTree::get_rpc_sender_id); ClassDB::bind_method(D_METHOD("set_refuse_new_network_connections", "refuse"), &SceneTree::set_refuse_new_network_connections); ClassDB::bind_method(D_METHOD("is_refusing_new_network_connections"), &SceneTree::is_refusing_new_network_connections); ClassDB::bind_method(D_METHOD("_network_peer_connected"), &SceneTree::_network_peer_connected); @@ -2263,6 +2274,7 @@ SceneTree::SceneTree() { call_lock = 0; root_lock = 0; node_count = 0; + rpc_sender_id = 0; //create with mainloop diff --git a/scene/main/scene_tree.h b/scene/main/scene_tree.h index c62607244e..1de9a2ce8c 100644 --- a/scene/main/scene_tree.h +++ b/scene/main/scene_tree.h @@ -199,6 +199,8 @@ private: void _connection_failed(); void _server_disconnected(); + int rpc_sender_id; + //path sent caches struct PathSentCache { Map<int, bool> confirmed_peers; @@ -445,6 +447,7 @@ public: bool has_network_peer() const; int get_network_unique_id() const; Vector<int> get_network_connected_peers() const; + int get_rpc_sender_id() const; void set_refuse_new_network_connections(bool p_refuse); bool is_refusing_new_network_connections() const; diff --git a/servers/physics/broad_phase_basic.cpp b/servers/physics/broad_phase_basic.cpp index 05a2e1fdf8..5a54e1f0d9 100644 --- a/servers/physics/broad_phase_basic.cpp +++ b/servers/physics/broad_phase_basic.cpp @@ -30,17 +30,14 @@ #include "broad_phase_basic.h" #include "list.h" #include "print_string.h" -BroadPhaseSW::ID BroadPhaseBasic::create(CollisionObjectSW *p_object_, int p_subindex) { +BroadPhaseSW::ID BroadPhaseBasic::create(CollisionObjectSW *p_object, int p_subindex) { - if (p_object_ == NULL) { - - ERR_FAIL_COND_V(p_object_ == NULL, 0); - } + ERR_FAIL_COND_V(p_object == NULL, NULL); current++; Element e; - e.owner = p_object_; + e.owner = p_object; e._static = false; e.subindex = p_subindex; diff --git a/servers/visual/shader_language.cpp b/servers/visual/shader_language.cpp index 3e0a1a6f45..7146814cbe 100644 --- a/servers/visual/shader_language.cpp +++ b/servers/visual/shader_language.cpp @@ -1041,6 +1041,12 @@ bool ShaderLanguage::_validate_operator(OperatorNode *p_op, DataType *r_ret_type } } break; case OP_ASSIGN: { + + if (p_op->arguments[0]->type != Node::TYPE_MEMBER && p_op->arguments[0]->type != Node::TYPE_VARIABLE) { + valid = false; + break; + } + DataType na = p_op->arguments[0]->get_datatype(); DataType nb = p_op->arguments[1]->get_datatype(); valid = na == nb; diff --git a/servers/visual/visual_server_canvas.cpp b/servers/visual/visual_server_canvas.cpp index 13517fa409..931e084246 100644 --- a/servers/visual/visual_server_canvas.cpp +++ b/servers/visual/visual_server_canvas.cpp @@ -1099,13 +1099,15 @@ void VisualServerCanvas::canvas_light_occluder_set_polygon(RID p_occluder, RID p if (occluder->polygon.is_valid()) { LightOccluderPolygon *occluder_poly = canvas_light_occluder_polygon_owner.get(p_polygon); - if (!occluder_poly) + if (!occluder_poly) { occluder->polygon = RID(); - ERR_FAIL_COND(!occluder_poly); - occluder_poly->owners.insert(occluder); - occluder->polygon_buffer = occluder_poly->occluder; - occluder->aabb_cache = occluder_poly->aabb; - occluder->cull_cache = occluder_poly->cull_mode; + ERR_FAIL_COND(!occluder_poly); + } else { + occluder_poly->owners.insert(occluder); + occluder->polygon_buffer = occluder_poly->occluder; + occluder->aabb_cache = occluder_poly->aabb; + occluder->cull_cache = occluder_poly->cull_mode; + } } } void VisualServerCanvas::canvas_light_occluder_set_transform(RID p_occluder, const Transform2D &p_xform) { diff --git a/servers/visual/visual_server_scene.cpp b/servers/visual/visual_server_scene.cpp index fc9583d793..a0c7420270 100644 --- a/servers/visual/visual_server_scene.cpp +++ b/servers/visual/visual_server_scene.cpp @@ -1482,11 +1482,10 @@ void VisualServerScene::_render_scene(const Transform p_cam_transform, const Cam if (light && p_shadow_atlas.is_valid() && VSG::storage->light_has_shadow(E->get()->base)) { lights_with_shadow[directional_shadow_count++] = E->get(); - } - - //add to list - directional_light_ptr[directional_light_count++] = light->instance; + //add to list + directional_light_ptr[directional_light_count++] = light->instance; + } } VSG::scene_render->set_directional_shadow_count(directional_shadow_count); |