diff --git a/core/color.cpp b/core/color.cpp index 9f740bed1c3..4b62c93668d 100644 --- a/core/color.cpp +++ b/core/color.cpp @@ -456,56 +456,9 @@ String Color::to_html(bool p_alpha) const { } Color Color::from_hsv(float p_h, float p_s, float p_v, float p_a) const { - - p_h = Math::fmod(p_h * 360.0f, 360.0f); - if (p_h < 0.0) - p_h += 360.0f; - - const float h_ = p_h / 60.0f; - const float c = p_v * p_s; - const float x = c * (1.0f - Math::abs(Math::fmod(h_, 2.0f) - 1.0f)); - float r, g, b; - - switch ((int)h_) { - case 0: { - r = c; - g = x; - b = 0; - } break; - case 1: { - r = x; - g = c; - b = 0; - } break; - case 2: { - r = 0; - g = c; - b = x; - } break; - case 3: { - r = 0; - g = x; - b = c; - } break; - case 4: { - r = x; - g = 0; - b = c; - } break; - case 5: { - r = c; - g = 0; - b = x; - } break; - default: { - r = 0; - g = 0; - b = 0; - } break; - } - - const float m = p_v - c; - return Color(m + r, m + g, m + b, p_a); + Color c; + c.set_hsv(p_h, p_s, p_v, p_a); + return c; } // FIXME: Remove once Godot 3.1 has been released diff --git a/core/io/http_client.cpp b/core/io/http_client.cpp index 3954f50f7a5..f2e8442df0a 100644 --- a/core/io/http_client.cpp +++ b/core/io/http_client.cpp @@ -100,6 +100,11 @@ void HTTPClient::set_connection(const Ref &p_connection) { ERR_FAIL_COND_MSG(p_connection.is_null(), "Connection is not a reference to a valid StreamPeer object."); + if (ssl) { + ERR_FAIL_NULL_MSG(Object::cast_to(p_connection.ptr()), + "Connection is not a reference to a valid StreamPeerSSL object."); + } + if (connection == p_connection) { return; } diff --git a/modules/mono/godotsharp_dirs.cpp b/modules/mono/godotsharp_dirs.cpp index d80e0c28145..c8dcc0fe676 100644 --- a/modules/mono/godotsharp_dirs.cpp +++ b/modules/mono/godotsharp_dirs.cpp @@ -180,16 +180,16 @@ private: #ifdef OSX_ENABLED if (!DirAccess::exists(data_editor_tools_dir)) { - data_editor_tools_dir = exe_dir.plus_file("../Frameworks/GodotSharp/Tools"); + data_editor_tools_dir = exe_dir.plus_file("../Resources/GodotSharp/Tools"); } if (!DirAccess::exists(data_editor_prebuilt_api_dir)) { - data_editor_prebuilt_api_dir = exe_dir.plus_file("../Frameworks/GodotSharp/Api"); + data_editor_prebuilt_api_dir = exe_dir.plus_file("../Resources/GodotSharp/Api"); } if (!DirAccess::exists(data_mono_root_dir)) { data_mono_etc_dir = exe_dir.plus_file("../Resources/GodotSharp/Mono/etc"); - data_mono_lib_dir = exe_dir.plus_file("../Frameworks/GodotSharp/Mono/lib"); + data_mono_lib_dir = exe_dir.plus_file("../Resources/GodotSharp/Mono/lib"); } #endif @@ -219,11 +219,11 @@ private: #ifdef OSX_ENABLED if (!DirAccess::exists(data_mono_root_dir)) { data_mono_etc_dir = exe_dir.plus_file("../Resources/GodotSharp/Mono/etc"); - data_mono_lib_dir = exe_dir.plus_file("../Frameworks/GodotSharp/Mono/lib"); + data_mono_lib_dir = exe_dir.plus_file("../Resources/GodotSharp/Mono/lib"); } if (!DirAccess::exists(data_game_assemblies_dir)) { - data_game_assemblies_dir = exe_dir.plus_file("../Frameworks/GodotSharp/Assemblies"); + data_game_assemblies_dir = exe_dir.plus_file("../Resources/GodotSharp/Assemblies"); } #endif diff --git a/platform/osx/detect.py b/platform/osx/detect.py index 3572fae2169..8220d53b866 100644 --- a/platform/osx/detect.py +++ b/platform/osx/detect.py @@ -29,6 +29,7 @@ def get_opts(): BoolVariable("separate_debug_symbols", "Create a separate file containing debugging symbols", False), BoolVariable("use_ubsan", "Use LLVM/GCC compiler undefined behavior sanitizer (UBSAN)", False), BoolVariable("use_asan", "Use LLVM/GCC compiler address sanitizer (ASAN))", False), + BoolVariable("use_lsan", "Use LLVM/GCC compiler leak sanitizer (LSAN))", False), BoolVariable("use_tsan", "Use LLVM/GCC compiler thread sanitizer (TSAN))", False), ] @@ -127,7 +128,7 @@ def configure(env): env["AS"] = basecmd + "as" env.Append(CPPDEFINES=["__MACPORTS__"]) # hack to fix libvpx MM256_BROADCASTSI128_SI256 define - if env["use_ubsan"] or env["use_asan"] or env["use_tsan"]: + if env["use_ubsan"] or env["use_asan"] or env["use_lsan"] or env["use_tsan"]: env.extra_suffix += "s" if env["use_ubsan"]: @@ -138,6 +139,10 @@ def configure(env): env.Append(CCFLAGS=["-fsanitize=address"]) env.Append(LINKFLAGS=["-fsanitize=address"]) + if env["use_lsan"]: + env.Append(CCFLAGS=["-fsanitize=leak"]) + env.Append(LINKFLAGS=["-fsanitize=leak"]) + if env["use_tsan"]: env.Append(CCFLAGS=["-fsanitize=thread"]) env.Append(LINKFLAGS=["-fsanitize=thread"]) diff --git a/platform/osx/export/export.cpp b/platform/osx/export/export.cpp index 7448fb30279..5fd7d40040c 100644 --- a/platform/osx/export/export.cpp +++ b/platform/osx/export/export.cpp @@ -634,14 +634,14 @@ Error EditorExportPlatformOSX::export_project(const Ref &p_p ret = unzGoToNextFile(src_pkg_zip); continue; // skip } - file = file.replace("/data.mono.osx.64.release_debug/", "/data_" + pkg_name + "/"); + file = file.replace("/data.mono.osx.64.release_debug/", "/GodotSharp/"); } if (file.find("/data.mono.osx.64.release/") != -1) { if (p_debug) { ret = unzGoToNextFile(src_pkg_zip); continue; // skip } - file = file.replace("/data.mono.osx.64.release/", "/data_" + pkg_name + "/"); + file = file.replace("/data.mono.osx.64.release/", "/GodotSharp/"); } if (file.ends_with(".dylib")) { diff --git a/platform/server/detect.py b/platform/server/detect.py index b7dfab5ad8f..ed85b9b7b1b 100644 --- a/platform/server/detect.py +++ b/platform/server/detect.py @@ -38,6 +38,7 @@ def get_opts(): BoolVariable("use_lsan", "Use LLVM/GCC compiler leak sanitizer (LSAN))", False), BoolVariable("use_tsan", "Use LLVM/GCC compiler thread sanitizer (TSAN))", False), BoolVariable("debug_symbols", "Add debugging symbols to release/release_debug builds", True), + BoolVariable("use_msan", "Use LLVM/GCC compiler memory sanitizer (MSAN))", False), BoolVariable("separate_debug_symbols", "Create a separate file containing debugging symbols", False), BoolVariable("execinfo", "Use libexecinfo on systems where glibc is not available", False), ] @@ -94,7 +95,7 @@ def configure(env): env.extra_suffix = ".llvm" + env.extra_suffix env.Append(LIBS=["atomic"]) - if env["use_ubsan"] or env["use_asan"] or env["use_lsan"] or env["use_tsan"]: + if env["use_ubsan"] or env["use_asan"] or env["use_lsan"] or env["use_tsan"] or env["use_msan"]: env.extra_suffix += "s" if env["use_ubsan"]: @@ -113,6 +114,10 @@ def configure(env): env.Append(CCFLAGS=["-fsanitize=thread"]) env.Append(LINKFLAGS=["-fsanitize=thread"]) + if env["use_msan"]: + env.Append(CCFLAGS=["-fsanitize=memory"]) + env.Append(LINKFLAGS=["-fsanitize=memory"]) + if env["use_lto"]: env.Append(CCFLAGS=["-flto"]) if not env["use_llvm"] and env.GetOption("num_jobs") > 1: diff --git a/platform/x11/detect.py b/platform/x11/detect.py index 3f63c6538dd..b8c509ad9bf 100644 --- a/platform/x11/detect.py +++ b/platform/x11/detect.py @@ -70,6 +70,7 @@ def get_opts(): BoolVariable("use_asan", "Use LLVM/GCC compiler address sanitizer (ASAN))", False), BoolVariable("use_lsan", "Use LLVM/GCC compiler leak sanitizer (LSAN))", False), BoolVariable("use_tsan", "Use LLVM/GCC compiler thread sanitizer (TSAN))", False), + BoolVariable("use_msan", "Use LLVM/GCC compiler memory sanitizer (MSAN))", False), BoolVariable("pulseaudio", "Detect and use PulseAudio", True), BoolVariable("udev", "Use udev for gamepad connection callbacks", True), BoolVariable("debug_symbols", "Add debugging symbols to release/release_debug builds", True), @@ -140,7 +141,7 @@ def configure(env): print("Using LLD with GCC is not supported yet, try compiling with 'use_llvm=yes'.") sys.exit(255) - if env["use_ubsan"] or env["use_asan"] or env["use_lsan"] or env["use_tsan"]: + if env["use_ubsan"] or env["use_asan"] or env["use_lsan"] or env["use_tsan"] or env["use_msan"]: env.extra_suffix += "s" if env["use_ubsan"]: @@ -172,6 +173,10 @@ def configure(env): env.Append(CCFLAGS=["-fsanitize=thread"]) env.Append(LINKFLAGS=["-fsanitize=thread"]) + if env["use_msan"]: + env.Append(CCFLAGS=["-fsanitize=memory"]) + env.Append(LINKFLAGS=["-fsanitize=memory"]) + if env["use_lto"]: if not env["use_llvm"] and env.GetOption("num_jobs") > 1: env.Append(CCFLAGS=["-flto"]) diff --git a/scene/2d/camera_2d.cpp b/scene/2d/camera_2d.cpp index 43d9310a87b..ca16244ad64 100644 --- a/scene/2d/camera_2d.cpp +++ b/scene/2d/camera_2d.cpp @@ -269,6 +269,7 @@ void Camera2D::_notification(int p_what) { viewport = NULL; } break; +#ifdef TOOLS_ENABLED case NOTIFICATION_DRAW: { if (!is_inside_tree() || !Engine::get_singleton()->is_editor_hint()) @@ -345,8 +346,8 @@ void Camera2D::_notification(int p_what) { draw_line(inv_transform.xform(margin_endpoints[i]), inv_transform.xform(margin_endpoints[(i + 1) % 4]), margin_drawing_color, margin_drawing_width); } } - } break; +#endif } } @@ -644,7 +645,9 @@ Node *Camera2D::get_custom_viewport() const { void Camera2D::set_screen_drawing_enabled(bool enable) { screen_drawing_enabled = enable; +#ifdef TOOLS_ENABLED update(); +#endif } bool Camera2D::is_screen_drawing_enabled() const { @@ -653,7 +656,9 @@ bool Camera2D::is_screen_drawing_enabled() const { void Camera2D::set_limit_drawing_enabled(bool enable) { limit_drawing_enabled = enable; +#ifdef TOOLS_ENABLED update(); +#endif } bool Camera2D::is_limit_drawing_enabled() const { @@ -662,7 +667,9 @@ bool Camera2D::is_limit_drawing_enabled() const { void Camera2D::set_margin_drawing_enabled(bool enable) { margin_drawing_enabled = enable; +#ifdef TOOLS_ENABLED update(); +#endif } bool Camera2D::is_margin_drawing_enabled() const { diff --git a/scene/3d/baked_lightmap.cpp b/scene/3d/baked_lightmap.cpp index 13dab2e75ad..b7b7fde2e0a 100644 --- a/scene/3d/baked_lightmap.cpp +++ b/scene/3d/baked_lightmap.cpp @@ -156,6 +156,7 @@ void BakedLightmapData::clear_data() { } void BakedLightmapData::_set_user_data(const Array &p_data) { + ERR_FAIL_COND(p_data.size() <= 0); // Detect old lightmapper format if (p_data.size() % 3 == 0) { diff --git a/scene/3d/navigation_mesh.cpp b/scene/3d/navigation_mesh.cpp index d803dba89e7..bccb0b9d324 100644 --- a/scene/3d/navigation_mesh.cpp +++ b/scene/3d/navigation_mesh.cpp @@ -33,6 +33,7 @@ #include "navigation.h" void NavigationMesh::create_from_mesh(const Ref &p_mesh) { + ERR_FAIL_COND(p_mesh.is_null()); vertices = PoolVector(); clear_polygons(); diff --git a/scene/gui/tree.cpp b/scene/gui/tree.cpp index 64c6dc55236..b8e71d9fcc7 100644 --- a/scene/gui/tree.cpp +++ b/scene/gui/tree.cpp @@ -3203,11 +3203,11 @@ void Tree::item_selected(int p_column, TreeItem *p_item) { void Tree::item_deselected(int p_column, TreeItem *p_item) { if (selected_item == p_item) { - selected_item = NULL; - } + selected_item = nullptr; - if (selected_col == p_column) { - selected_col = -1; + if (selected_col == p_column) { + selected_col = -1; + } } if (select_mode == SELECT_MULTI || select_mode == SELECT_SINGLE) { diff --git a/scene/main/http_request.cpp b/scene/main/http_request.cpp index 8a5ccce375b..ec49689acaa 100644 --- a/scene/main/http_request.cpp +++ b/scene/main/http_request.cpp @@ -347,6 +347,9 @@ bool HTTPRequest::_update_connection() { } client->poll(); + if (client->get_status() != HTTPClient::STATUS_BODY) { + return false; + } PoolByteArray chunk = client->read_response_body_chunk(); downloaded.add(chunk.size()); diff --git a/scene/resources/texture.cpp b/scene/resources/texture.cpp index 17e67c2a20c..362ec78808b 100644 --- a/scene/resources/texture.cpp +++ b/scene/resources/texture.cpp @@ -196,7 +196,7 @@ void ImageTexture::create(int p_width, int p_height, Image::Format p_format, uin } void ImageTexture::create_from_image(const Ref &p_image, uint32_t p_flags) { - ERR_FAIL_COND(p_image.is_null()); + ERR_FAIL_COND_MSG(p_image.is_null() || p_image->empty(), "Invalid image"); flags = p_flags; w = p_image->get_width(); h = p_image->get_height();