Browse Source

Merge pull request #46658 from akien-mga/3.2-cherrypicks

 Cherry-picks for the 3.2 branch (future 3.2.4) - 27th batch
Rémi Verschelde 4 years ago
parent
commit
60f1219897

+ 3 - 50
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 {
 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
 // FIXME: Remove once Godot 3.1 has been released

+ 5 - 0
core/io/http_client.cpp

@@ -100,6 +100,11 @@ void HTTPClient::set_connection(const Ref<StreamPeer> &p_connection) {
 
 
 	ERR_FAIL_COND_MSG(p_connection.is_null(), "Connection is not a reference to a valid StreamPeer object.");
 	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<StreamPeerSSL>(p_connection.ptr()),
+				"Connection is not a reference to a valid StreamPeerSSL object.");
+	}
+
 	if (connection == p_connection) {
 	if (connection == p_connection) {
 		return;
 		return;
 	}
 	}

+ 5 - 5
modules/mono/godotsharp_dirs.cpp

@@ -180,16 +180,16 @@ private:
 
 
 #ifdef OSX_ENABLED
 #ifdef OSX_ENABLED
 		if (!DirAccess::exists(data_editor_tools_dir)) {
 		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)) {
 		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)) {
 		if (!DirAccess::exists(data_mono_root_dir)) {
 			data_mono_etc_dir = exe_dir.plus_file("../Resources/GodotSharp/Mono/etc");
 			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
 #endif
 
 
@@ -219,11 +219,11 @@ private:
 #ifdef OSX_ENABLED
 #ifdef OSX_ENABLED
 		if (!DirAccess::exists(data_mono_root_dir)) {
 		if (!DirAccess::exists(data_mono_root_dir)) {
 			data_mono_etc_dir = exe_dir.plus_file("../Resources/GodotSharp/Mono/etc");
 			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)) {
 		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
 #endif
 
 

+ 6 - 1
platform/osx/detect.py

@@ -29,6 +29,7 @@ def get_opts():
         BoolVariable("separate_debug_symbols", "Create a separate file containing debugging symbols", False),
         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_ubsan", "Use LLVM/GCC compiler undefined behavior sanitizer (UBSAN)", False),
         BoolVariable("use_asan", "Use LLVM/GCC compiler address sanitizer (ASAN))", 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),
         BoolVariable("use_tsan", "Use LLVM/GCC compiler thread sanitizer (TSAN))", False),
     ]
     ]
 
 
@@ -127,7 +128,7 @@ def configure(env):
         env["AS"] = basecmd + "as"
         env["AS"] = basecmd + "as"
         env.Append(CPPDEFINES=["__MACPORTS__"])  # hack to fix libvpx MM256_BROADCASTSI128_SI256 define
         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"
         env.extra_suffix += "s"
 
 
         if env["use_ubsan"]:
         if env["use_ubsan"]:
@@ -138,6 +139,10 @@ def configure(env):
             env.Append(CCFLAGS=["-fsanitize=address"])
             env.Append(CCFLAGS=["-fsanitize=address"])
             env.Append(LINKFLAGS=["-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"]:
         if env["use_tsan"]:
             env.Append(CCFLAGS=["-fsanitize=thread"])
             env.Append(CCFLAGS=["-fsanitize=thread"])
             env.Append(LINKFLAGS=["-fsanitize=thread"])
             env.Append(LINKFLAGS=["-fsanitize=thread"])

+ 2 - 2
platform/osx/export/export.cpp

@@ -634,14 +634,14 @@ Error EditorExportPlatformOSX::export_project(const Ref<EditorExportPreset> &p_p
 					ret = unzGoToNextFile(src_pkg_zip);
 					ret = unzGoToNextFile(src_pkg_zip);
 					continue; // skip
 					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 (file.find("/data.mono.osx.64.release/") != -1) {
 				if (p_debug) {
 				if (p_debug) {
 					ret = unzGoToNextFile(src_pkg_zip);
 					ret = unzGoToNextFile(src_pkg_zip);
 					continue; // skip
 					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")) {
 			if (file.ends_with(".dylib")) {

+ 6 - 1
platform/server/detect.py

@@ -38,6 +38,7 @@ def get_opts():
         BoolVariable("use_lsan", "Use LLVM/GCC compiler leak sanitizer (LSAN))", 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_tsan", "Use LLVM/GCC compiler thread sanitizer (TSAN))", False),
         BoolVariable("debug_symbols", "Add debugging symbols to release/release_debug builds", True),
         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("separate_debug_symbols", "Create a separate file containing debugging symbols", False),
         BoolVariable("execinfo", "Use libexecinfo on systems where glibc is not available", 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.extra_suffix = ".llvm" + env.extra_suffix
         env.Append(LIBS=["atomic"])
         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"
         env.extra_suffix += "s"
 
 
         if env["use_ubsan"]:
         if env["use_ubsan"]:
@@ -113,6 +114,10 @@ def configure(env):
             env.Append(CCFLAGS=["-fsanitize=thread"])
             env.Append(CCFLAGS=["-fsanitize=thread"])
             env.Append(LINKFLAGS=["-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 env["use_lto"]:
         env.Append(CCFLAGS=["-flto"])
         env.Append(CCFLAGS=["-flto"])
         if not env["use_llvm"] and env.GetOption("num_jobs") > 1:
         if not env["use_llvm"] and env.GetOption("num_jobs") > 1:

+ 6 - 1
platform/x11/detect.py

@@ -70,6 +70,7 @@ def get_opts():
         BoolVariable("use_asan", "Use LLVM/GCC compiler address sanitizer (ASAN))", 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_lsan", "Use LLVM/GCC compiler leak sanitizer (LSAN))", False),
         BoolVariable("use_tsan", "Use LLVM/GCC compiler thread sanitizer (TSAN))", 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("pulseaudio", "Detect and use PulseAudio", True),
         BoolVariable("udev", "Use udev for gamepad connection callbacks", True),
         BoolVariable("udev", "Use udev for gamepad connection callbacks", True),
         BoolVariable("debug_symbols", "Add debugging symbols to release/release_debug builds", 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'.")
             print("Using LLD with GCC is not supported yet, try compiling with 'use_llvm=yes'.")
             sys.exit(255)
             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"
         env.extra_suffix += "s"
 
 
         if env["use_ubsan"]:
         if env["use_ubsan"]:
@@ -172,6 +173,10 @@ def configure(env):
             env.Append(CCFLAGS=["-fsanitize=thread"])
             env.Append(CCFLAGS=["-fsanitize=thread"])
             env.Append(LINKFLAGS=["-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 env["use_lto"]:
         if not env["use_llvm"] and env.GetOption("num_jobs") > 1:
         if not env["use_llvm"] and env.GetOption("num_jobs") > 1:
             env.Append(CCFLAGS=["-flto"])
             env.Append(CCFLAGS=["-flto"])

+ 8 - 1
scene/2d/camera_2d.cpp

@@ -269,6 +269,7 @@ void Camera2D::_notification(int p_what) {
 			viewport = NULL;
 			viewport = NULL;
 
 
 		} break;
 		} break;
+#ifdef TOOLS_ENABLED
 		case NOTIFICATION_DRAW: {
 		case NOTIFICATION_DRAW: {
 
 
 			if (!is_inside_tree() || !Engine::get_singleton()->is_editor_hint())
 			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);
 					draw_line(inv_transform.xform(margin_endpoints[i]), inv_transform.xform(margin_endpoints[(i + 1) % 4]), margin_drawing_color, margin_drawing_width);
 				}
 				}
 			}
 			}
-
 		} break;
 		} break;
+#endif
 	}
 	}
 }
 }
 
 
@@ -644,7 +645,9 @@ Node *Camera2D::get_custom_viewport() const {
 
 
 void Camera2D::set_screen_drawing_enabled(bool enable) {
 void Camera2D::set_screen_drawing_enabled(bool enable) {
 	screen_drawing_enabled = enable;
 	screen_drawing_enabled = enable;
+#ifdef TOOLS_ENABLED
 	update();
 	update();
+#endif
 }
 }
 
 
 bool Camera2D::is_screen_drawing_enabled() const {
 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) {
 void Camera2D::set_limit_drawing_enabled(bool enable) {
 	limit_drawing_enabled = enable;
 	limit_drawing_enabled = enable;
+#ifdef TOOLS_ENABLED
 	update();
 	update();
+#endif
 }
 }
 
 
 bool Camera2D::is_limit_drawing_enabled() const {
 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) {
 void Camera2D::set_margin_drawing_enabled(bool enable) {
 	margin_drawing_enabled = enable;
 	margin_drawing_enabled = enable;
+#ifdef TOOLS_ENABLED
 	update();
 	update();
+#endif
 }
 }
 
 
 bool Camera2D::is_margin_drawing_enabled() const {
 bool Camera2D::is_margin_drawing_enabled() const {

+ 1 - 0
scene/3d/baked_lightmap.cpp

@@ -156,6 +156,7 @@ void BakedLightmapData::clear_data() {
 }
 }
 
 
 void BakedLightmapData::_set_user_data(const Array &p_data) {
 void BakedLightmapData::_set_user_data(const Array &p_data) {
+	ERR_FAIL_COND(p_data.size() <= 0);
 
 
 	// Detect old lightmapper format
 	// Detect old lightmapper format
 	if (p_data.size() % 3 == 0) {
 	if (p_data.size() % 3 == 0) {

+ 1 - 0
scene/3d/navigation_mesh.cpp

@@ -33,6 +33,7 @@
 #include "navigation.h"
 #include "navigation.h"
 
 
 void NavigationMesh::create_from_mesh(const Ref<Mesh> &p_mesh) {
 void NavigationMesh::create_from_mesh(const Ref<Mesh> &p_mesh) {
+	ERR_FAIL_COND(p_mesh.is_null());
 
 
 	vertices = PoolVector<Vector3>();
 	vertices = PoolVector<Vector3>();
 	clear_polygons();
 	clear_polygons();

+ 4 - 4
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) {
 void Tree::item_deselected(int p_column, TreeItem *p_item) {
 	if (selected_item == 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) {
 	if (select_mode == SELECT_MULTI || select_mode == SELECT_SINGLE) {

+ 3 - 0
scene/main/http_request.cpp

@@ -347,6 +347,9 @@ bool HTTPRequest::_update_connection() {
 			}
 			}
 
 
 			client->poll();
 			client->poll();
+			if (client->get_status() != HTTPClient::STATUS_BODY) {
+				return false;
+			}
 
 
 			PoolByteArray chunk = client->read_response_body_chunk();
 			PoolByteArray chunk = client->read_response_body_chunk();
 			downloaded.add(chunk.size());
 			downloaded.add(chunk.size());

+ 1 - 1
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<Image> &p_image, uint32_t p_flags) {
 void ImageTexture::create_from_image(const Ref<Image> &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;
 	flags = p_flags;
 	w = p_image->get_width();
 	w = p_image->get_width();
 	h = p_image->get_height();
 	h = p_image->get_height();