new_editor: tighten window workspace validation
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
#include <XCEditor/Workspace/UIEditorWindowWorkspaceModel.h>
|
||||
#include <XCEditor/Workspace/UIEditorWorkspaceValidation.h>
|
||||
|
||||
#include <unordered_map>
|
||||
#include <unordered_set>
|
||||
#include <utility>
|
||||
|
||||
@@ -87,6 +88,7 @@ UIEditorWindowWorkspaceValidationResult ValidateUIEditorWindowWorkspaceSet(
|
||||
}
|
||||
|
||||
std::unordered_set<std::string> seenWindowIds = {};
|
||||
std::unordered_map<std::string, std::string> panelOwners = {};
|
||||
bool hasPrimaryWindow = false;
|
||||
bool hasActiveWindow = false;
|
||||
for (const UIEditorWindowWorkspaceState& state : windowSet.windows) {
|
||||
@@ -126,6 +128,17 @@ UIEditorWindowWorkspaceValidationResult ValidateUIEditorWindowWorkspaceSet(
|
||||
"Window '" + state.windowId + "' session invalid: " +
|
||||
sessionValidation.message);
|
||||
}
|
||||
|
||||
for (const UIEditorPanelSessionState& panelState : state.session.panelStates) {
|
||||
const auto [ownerIt, inserted] =
|
||||
panelOwners.emplace(panelState.panelId, state.windowId);
|
||||
if (!inserted) {
|
||||
return MakeValidationError(
|
||||
UIEditorWindowWorkspaceValidationCode::DuplicatePanelAcrossWindows,
|
||||
"Panel '" + panelState.panelId + "' is present in both window '" +
|
||||
ownerIt->second + "' and window '" + state.windowId + "'.");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (!hasPrimaryWindow) {
|
||||
|
||||
Reference in New Issue
Block a user