fac4ca0c74
Render layer overrides only reached disk on an explicit File > Save -- SaveDirtyRenderLayers() was called from SaveUsdFile/SaveUsdFileAs and nowhere else. Everything a user authored after switching to a render layer (property values, shader parameters, material assignments) sat in a dirty in-memory SdfLayer marked with an orange asterisk, and a crash took the whole layer's overrides with it. Application::Update() now polls the active render layer's IsDirty() and saves it 0.5s after the user goes idle, gated on IsAnyItemActive() and the left mouse button so a slider or gizmo drag produces one write on release rather than one per frame. Polling rather than hooking CommandHistory::Push/Undo/Redo is deliberate: many of the writes this is meant to catch never build a command and author straight to the ambient edit target -- PropertyPanel's live WriteTranslate/Rotate/Scale and its generic attribute widgets, TransformManipulator's gizmo drags, and MaterialEditorPanel::RenderInputWidget's shader input writes. A command hook would have silently missed exactly the property and shader-parameter edits at issue. IsDirty() catches every path, commanded or not. Scope is the active layer only. Muted render layers still rely on SaveDirtyRenderLayers() at save time, and the root layer is never auto-written -- so the persisted active-layer choice (custom layer data on the root layer) still only survives a reopen once the stage itself is saved. Auto-writing the user's main scene file was ruled out. - SaveRenderLayerIfDirty() refreshes LayerManager after a successful save, or the cached isDirty snapshot leaves a stale asterisk in StageEditorPanel and the Scene Hierarchy sublayer list. A failed save latches the layer id so a read-only file can't spam the log twice a second. - Switching layers flushes the outgoing one, and Shutdown() flushes before the panels are destroyed, so edits inside the debounce window aren't stranded. - RefreshManagers() clears the auto-save state, whose layer ids belong to the outgoing stage. - New "Auto-save active layer" checkbox in the Render Layer panel, on by default, persisted as AutoSaveRenderLayer in preferences.ini. See docs/adr/0002-render-layer.md D9-D11 for the rationale. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>