Browse Source

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

Cherry-picks for the 3.2 branch (future 3.2.4) - 9th batch
Rémi Verschelde 4 years ago
parent
commit
06389f705b

+ 10 - 0
core/engine.cpp

@@ -236,3 +236,13 @@ Engine::Engine() {
 	_frame_step = 0;
 	editor_hint = false;
 }
+
+Engine::Singleton::Singleton(const StringName &p_name, Object *p_ptr) :
+		name(p_name),
+		ptr(p_ptr) {
+#ifdef DEBUG_ENABLED
+	if (Object::cast_to<Reference>(p_ptr)) {
+		ERR_PRINT("A class intended to be used as a singleton must *not* inherit from Reference.");
+	}
+#endif
+}

+ 1 - 4
core/engine.h

@@ -42,10 +42,7 @@ public:
 	struct Singleton {
 		StringName name;
 		Object *ptr;
-		Singleton(const StringName &p_name = StringName(), Object *p_ptr = NULL) :
-				name(p_name),
-				ptr(p_ptr) {
-		}
+		Singleton(const StringName &p_name = StringName(), Object *p_ptr = NULL);
 	};
 
 private:

+ 3 - 5
core/resource.cpp

@@ -155,8 +155,8 @@ Ref<Resource> Resource::duplicate_for_local_scene(Node *p_for_scene, Map<Ref<Res
 	List<PropertyInfo> plist;
 	get_property_list(&plist);
 
-	Resource *r = Object::cast_to<Resource>(ClassDB::instance(get_class()));
-	ERR_FAIL_COND_V(!r, Ref<Resource>());
+	Ref<Resource> r = Object::cast_to<Resource>(ClassDB::instance(get_class()));
+	ERR_FAIL_COND_V(r.is_null(), Ref<Resource>());
 
 	r->local_scene = p_for_scene;
 
@@ -186,9 +186,7 @@ Ref<Resource> Resource::duplicate_for_local_scene(Node *p_for_scene, Map<Ref<Res
 		r->set(E->get().name, p);
 	}
 
-	RES res = Ref<Resource>(r);
-
-	return res;
+	return r;
 }
 
 void Resource::configure_for_local_scene(Node *p_for_scene, Map<Ref<Resource>, Ref<Resource> > &remap_cache) {

+ 1 - 1
doc/classes/SceneTree.xml

@@ -188,7 +188,7 @@
 			<argument index="0" name="exit_code" type="int" default="-1">
 			</argument>
 			<description>
-				Quits the application. A process [code]exit_code[/code] can optionally be passed as an argument. If this argument is [code]0[/code] or greater, it will override the [member OS.exit_code] defined before quitting the application.
+				Quits the application at the end of the current iteration. A process [code]exit_code[/code] can optionally be passed as an argument. If this argument is [code]0[/code] or greater, it will override the [member OS.exit_code] defined before quitting the application.
 			</description>
 		</method>
 		<method name="reload_current_scene">

+ 1 - 1
editor/plugins/canvas_item_editor_plugin.cpp

@@ -1491,7 +1491,7 @@ bool CanvasItemEditor::_gui_input_rotate(const Ref<InputEvent> &p_event) {
 	// Start rotation
 	if (drag_type == DRAG_NONE) {
 		if (b.is_valid() && b->get_button_index() == BUTTON_LEFT && b->is_pressed()) {
-			if ((b->get_control() && !b->get_alt() && tool == TOOL_SELECT) || tool == TOOL_ROTATE) {
+			if ((b->get_command() && !b->get_alt() && tool == TOOL_SELECT) || tool == TOOL_ROTATE) {
 				List<CanvasItem *> selection = _get_edited_canvas_items();
 
 				// Remove not movable nodes

+ 2 - 0
editor/plugins/spatial_editor_plugin.cpp

@@ -4993,6 +4993,8 @@ void SpatialEditor::_menu_item_pressed(int p_option) {
 					}
 				}
 			}
+			_finish_grid();
+			_init_grid();
 
 			view_menu->get_popup()->set_item_checked(view_menu->get_popup()->get_item_index(p_option), grid_enabled);
 

+ 3 - 0
editor/plugins/tile_set_editor_plugin.cpp

@@ -517,6 +517,7 @@ TileSetEditor::TileSetEditor(EditorNode *p_editor) {
 	tools[SHAPE_NEW_RECTANGLE]->set_button_group(tg);
 	tools[SHAPE_NEW_RECTANGLE]->set_tooltip(TTR("Create a new rectangle."));
 	tools[SHAPE_NEW_RECTANGLE]->connect("pressed", this, "_on_tool_clicked", varray(SHAPE_NEW_RECTANGLE));
+	tools[SHAPE_NEW_RECTANGLE]->set_shortcut(ED_SHORTCUT("tileset_editor/shape_new_rectangle", TTR("New Rectangle"), KEY_MASK_SHIFT | KEY_R));
 
 	tools[SHAPE_NEW_POLYGON] = memnew(ToolButton);
 	toolbar->add_child(tools[SHAPE_NEW_POLYGON]);
@@ -524,6 +525,7 @@ TileSetEditor::TileSetEditor(EditorNode *p_editor) {
 	tools[SHAPE_NEW_POLYGON]->set_button_group(tg);
 	tools[SHAPE_NEW_POLYGON]->set_tooltip(TTR("Create a new polygon."));
 	tools[SHAPE_NEW_POLYGON]->connect("pressed", this, "_on_tool_clicked", varray(SHAPE_NEW_POLYGON));
+	tools[SHAPE_NEW_POLYGON]->set_shortcut(ED_SHORTCUT("tileset_editor/shape_new_polygon", TTR("New Polygon"), KEY_MASK_SHIFT | KEY_P));
 
 	separator_shape_toggle = memnew(VSeparator);
 	toolbar->add_child(separator_shape_toggle);
@@ -535,6 +537,7 @@ TileSetEditor::TileSetEditor(EditorNode *p_editor) {
 	toolbar->add_child(separator_delete);
 	tools[SHAPE_DELETE] = memnew(ToolButton);
 	tools[SHAPE_DELETE]->connect("pressed", this, "_on_tool_clicked", varray(SHAPE_DELETE));
+	tools[SHAPE_DELETE]->set_shortcut(ED_SHORTCUT("tileset_editor/shape_delete", TTR("Delete Selected Shape"), KEY_MASK_SHIFT | KEY_BACKSPACE));
 	toolbar->add_child(tools[SHAPE_DELETE]);
 
 	spin_priority = memnew(SpinBox);

+ 2 - 2
editor/project_manager.cpp

@@ -2121,7 +2121,7 @@ void ProjectManager::_run_project_confirm() {
 		if (selected_main == "") {
 			run_error_diag->set_text(TTR("Can't run project: no main scene defined.\nPlease edit the project and set the main scene in the Project Settings under the \"Application\" category."));
 			run_error_diag->popup_centered();
-			return;
+			continue;
 		}
 
 		const String &selected = selected_list[i].project_key;
@@ -2130,7 +2130,7 @@ void ProjectManager::_run_project_confirm() {
 		if (!DirAccess::exists(path + "/.import")) {
 			run_error_diag->set_text(TTR("Can't run project: Assets need to be imported.\nPlease edit the project to trigger the initial import."));
 			run_error_diag->popup_centered();
-			return;
+			continue;
 		}
 
 		print_line("Running project: " + path + " (" + selected + ")");

+ 8 - 1
platform/android/export/export.cpp

@@ -2630,6 +2630,13 @@ public:
 
 	Error _zip_align_project(const String &sdk_path, const String &unaligned_file_path, const String &aligned_file_path) {
 		// Look for the zipalign tool.
+		String zipalign_command_name;
+#ifdef WINDOWS_ENABLED
+		zipalign_command_name = "zipalign.exe";
+#else
+		zipalign_command_name = "zipalign";
+#endif
+
 		String zipalign_command;
 		Error errn;
 		String build_tools_dir = sdk_path.plus_file("build-tools");
@@ -2644,7 +2651,7 @@ public:
 		while (!sub_dir.empty()) {
 			if (!sub_dir.begins_with(".") && da->current_is_dir()) {
 				// Check if the tool is here.
-				String tool_path = build_tools_dir.plus_file(sub_dir).plus_file("zipalign");
+				String tool_path = build_tools_dir.plus_file(sub_dir).plus_file(zipalign_command_name);
 				if (FileAccess::exists(tool_path)) {
 					zipalign_command = tool_path;
 					break;

+ 17 - 12
platform/osx/detect.py

@@ -45,9 +45,11 @@ def configure(env):
     if env["target"] == "release":
         if env["debug_symbols"] != "full":
             if env["optimize"] == "speed":  # optimize for speed (default)
-                env.Prepend(CCFLAGS=["-O3", "-fomit-frame-pointer", "-ftree-vectorize", "-msse2"])
+                env.Prepend(CCFLAGS=["-O3", "-fomit-frame-pointer", "-ftree-vectorize"])
             else:  # optimize for size
-                env.Prepend(CCFLAGS=["-Os", "-ftree-vectorize", "-msse2"])
+                env.Prepend(CCFLAGS=["-Os", "-ftree-vectorize"])
+            if env["arch"] != "arm64":
+                env.Prepend(CCFLAGS=["-msse2"])
 
         if env["debug_symbols"] == "yes":
             env.Prepend(CCFLAGS=["-g2"])
@@ -81,16 +83,16 @@ def configure(env):
     if "OSXCROSS_ROOT" in os.environ:
         env["osxcross"] = True
 
-    if not "osxcross" in env:  # regular native build
-        if env["arch"] == "arm64":
-            print("Building for macOS 10.15+, platform arm64.")
-            env.Append(CCFLAGS=["-arch", "arm64", "-mmacosx-version-min=10.15", "-target", "arm64-apple-macos10.15"])
-            env.Append(LINKFLAGS=["-arch", "arm64", "-mmacosx-version-min=10.15", "-target", "arm64-apple-macos10.15"])
-        else:
-            print("Building for macOS 10.9+, platform x86-64.")
-            env.Append(CCFLAGS=["-arch", "x86_64", "-mmacosx-version-min=10.9"])
-            env.Append(LINKFLAGS=["-arch", "x86_64", "-mmacosx-version-min=10.9"])
+    if env["arch"] == "arm64":
+        print("Building for macOS 10.15+, platform arm64.")
+        env.Append(CCFLAGS=["-arch", "arm64", "-mmacosx-version-min=10.15"])
+        env.Append(LINKFLAGS=["-arch", "arm64", "-mmacosx-version-min=10.15"])
+    else:
+        print("Building for macOS 10.9+, platform x86-64.")
+        env.Append(CCFLAGS=["-arch", "x86_64", "-mmacosx-version-min=10.9"])
+        env.Append(LINKFLAGS=["-arch", "x86_64", "-mmacosx-version-min=10.9"])
 
+    if not "osxcross" in env:  # regular native build
         if env["macports_clang"] != "no":
             mpprefix = os.environ.get("MACPORTS_PREFIX", "/opt/local")
             mpclangver = env["macports_clang"]
@@ -111,7 +113,10 @@ def configure(env):
 
     else:  # osxcross build
         root = os.environ.get("OSXCROSS_ROOT", 0)
-        basecmd = root + "/target/bin/x86_64-apple-" + env["osxcross_sdk"] + "-"
+        if env["arch"] == "arm64":
+            basecmd = root + "/target/bin/arm64-apple-" + env["osxcross_sdk"] + "-"
+        else:
+            basecmd = root + "/target/bin/x86_64-apple-" + env["osxcross_sdk"] + "-"
 
         ccache_path = os.environ.get("CCACHE")
         if ccache_path is None: