Explorar o código

Don't crash when the saved editor state contains fewer viewports than currently supported.

Sebastian Hartte %!s(int64=6) %!d(string=hai) anos
pai
achega
7bab7fd777
Modificáronse 1 ficheiros con 6 adicións e 2 borrados
  1. 6 2
      editor/plugins/spatial_editor_plugin.cpp

+ 6 - 2
editor/plugins/spatial_editor_plugin.cpp

@@ -4170,9 +4170,13 @@ void SpatialEditor::set_state(const Dictionary &p_state) {
 
 	if (d.has("viewports")) {
 		Array vp = d["viewports"];
-		ERR_FAIL_COND(vp.size() > 4);
+		uint32_t vp_size = static_cast<uint32_t>(vp.size());
+		if (vp_size > VIEWPORTS_COUNT) {
+			WARN_PRINT("Ignoring superfluous viewport settings from spatial editor state.")
+			vp_size = VIEWPORTS_COUNT;
+		}
 
-		for (uint32_t i = 0; i < VIEWPORTS_COUNT; i++) {
+		for (uint32_t i = 0; i < vp_size; i++) {
 			viewports[i]->set_state(vp[i]);
 		}
 	}