Merge pull request #26945 from shartte/allow-fewer-viewports-in-editor-state

Be more tolerant about under-defined spatial viewport state
This commit is contained in:
Rémi Verschelde 2019-03-13 20:11:24 +01:00 committed by GitHub
commit cad371dd85
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -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]);
}
}