| 1591 | auto KeyItr = ToolSessionKeys.Find(Tool); |
| 1592 | if (KeyItr == nullptr) |
| 1593 | { |
| 1594 | return; |
| 1595 | } |
| 1596 | |
| 1597 | const FString Key = (*KeyItr); |
| 1598 | ToolSessionKeys.Remove(Tool); |
| 1599 | |
| 1600 | CEditorSessionSettings* Settings = GetMutableDefault<CEditorSessionSettings>(); |
| 1601 | if (Settings == nullptr) |
| 1602 | { |
| 1603 | return; |
| 1604 | } |
| 1605 | |
| 1606 | const int32 TabIndex = Settings->OpenTabs.Find(Key); |
| 1607 | if (TabIndex == Constants::kIndexNone) |
| 1608 | { |
| 1609 | return; |
| 1610 | } |
| 1611 | |
| 1612 | // Ordered erase, not swap-and-pop, since the order of this list is the whole point. |
| 1613 | Settings->OpenTabs.RemoveAt(TabIndex); |
| 1614 | Global::GConfig->SaveSettings(CEditorSessionSettings::StaticClass()); |
| 1615 | } |
| 1616 | |
| 1617 | void FEditorUI::RestoreSessionTabs() |
| 1618 | { |
| 1619 | const CEditorSessionSettings* Settings = GetDefault<CEditorSessionSettings>(); |
| 1620 | if (Settings == nullptr || !Settings->bRestoreOpenTabs || Settings->OpenTabs.IsEmpty()) |
| 1621 | { |
| 1622 | return; |
| 1623 | } |
| 1624 | |
| 1625 | // A copy, since opening a tab writes back into the live list. |
| 1626 | const TVector<FString> Tabs = Settings->OpenTabs; |
| 1627 | |
| 1628 | // The retry below is another pass over the same list, skipping whatever an earlier pass restored. |
| 1629 | int32 NumUnscanned = 0; |
| 1630 | |
| 1631 | TVector<FString> Survivors; |
| 1632 | Survivors.Reserve(Tabs.Num()); |
| 1633 | |
| 1634 | for (const FString& Tab : Tabs) |
| 1635 | { |
| 1636 | // The retry fires on every registry change, so an import was enough to steal focus mid-click. |
| 1637 | if (RestoredSessionTabs.Contains(Tab)) |
| 1638 | { |
| 1639 | Survivors.Add(Tab); |
| 1640 | continue; |
| 1641 | } |
| 1642 | |
| 1643 | if (SessionKeyHasPrefix(Tab, GSessionAssetPrefix)) |
| 1644 | { |
| 1645 | const FString GuidText = Tab.Mid(static_cast<int32>(strlen(GSessionAssetPrefix))); |
| 1646 | const TOptional<FGuid> Guid = FGuid::TryParse(FStringView(*GuidText, GuidText.Len())); |
| 1647 | if (!Guid.IsSet()) |
| 1648 | { |
| 1649 | continue; // unparseable, so drop it |
| 1650 | } |
nothing calls this directly
no test coverage detected