Skip to content

Fix layout import missing content due to SourceList crash#471

Open
jmpatri615 wants to merge 2 commits into
Mechanical-Advantage:mainfrom
jmpatri615:dev/fix_layout_import
Open

Fix layout import missing content due to SourceList crash#471
jmpatri615 wants to merge 2 commits into
Mechanical-Advantage:mainfrom
jmpatri615:dev/fix_layout_import

Conversation

@jmpatri615
Copy link
Copy Markdown

  • Fix crash in SourceList.updateItem when an option-based color key is missing from state.options, which aborted layout restoration mid-way and caused missing tabs/content after import
  • Fix hubWindows array not cleaning up stale references when windows are closed, causing unnecessary iteration over destroyed windows

Test plan

  • Export a layout containing a Field2d tab with robot sources while connected to a data source
  • Import the layout and verify all tabs and source list items are fully restored
  • Verify no TypeError in the console during import
  • Close and reopen hub windows and verify the hubWindows array doesn't retain stale references

When hub windows are closed, they are not removed from the hubWindows
array. This causes stale references to destroyed windows to accumulate
over time, particularly during layout import where all existing windows
are closed and replaced. While most iteration sites guard with
isDestroyed() checks and sendMessage catches exceptions, the stale
entries still cause unnecessary iteration and represent a memory leak.

Add a "closed" event handler on each hub window to properly remove it
from the hubWindows array when it is closed.
SourceList.updateItem crashes with "Cannot read properties of undefined
(reading 'startsWith')" when a source list type config references an
option key for its color (e.g. "bumpers") but the item's options
dictionary does not contain that key. This happens during layout import
because source list items are restored before the data source populates
option values, causing the entire setState forEach to abort mid-way
through. As a result, remaining source list items and all subsequent
tabs fail to restore, leading to missing content in the imported layout.

Add a safe lookup for option-based colors so that a missing key falls
through to the default color instead of crashing.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant