stop the layout dialog opening for a shipyard with no schematic
Clearing a shipyard with "(None)" opened the layout configuration dialog on a
grid of no cells. The auto-open guard asked only whether the chosen id differs
from the current one, and the "(None)" option carries the empty id, which
differs from every schematic; ShipLayoutDialog then found no ship def and
derived a 0x0 grid. Predates this branch -- 698dd4d, 2026-07-13.
The question all three sites were answering by hand is now one:
findLayoutShipDef() returns the ship to configure a layout against, or nullptr
when no schematic is set, the id names no ship, or the ship defines no grid.
The auto-open path and the LayoutDialogRequestedEvent handler now ask it
before opening, and ShipyardContent asks it instead of spelling the same test
out for the preview and the Configure button.
The event handler was reachable only through a button ShipyardContent already
disables, so guarding it changes nothing today; it is guarded because the
dialog's precondition belongs to the dialog's entry, not to the widget that
happens to be the only caller.
REQ-MOD-UI-AUTO-DIALOG said "differs" and left clearing implicit, which is the
reading the code took. It now says clearing opens nothing.
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Ne3mejABZoLWKLh8fgpM3x
This commit is contained in:
@@ -63,4 +63,19 @@ struct ShipsConfig
|
||||
}
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
// The definition to configure a layout against, or nullptr when there is no layout
|
||||
// to configure: no schematic is selected at all (the empty id the "(None)" option
|
||||
// sets, REQ-UI-SELECT-OPTIONS), the id names no ship, or the ship defines no layout
|
||||
// grid. Every entry to the layout configuration dialog asks this before opening it
|
||||
// and the panel asks it before offering the button that opens it, so the dialog
|
||||
// cannot appear over a grid with no cells (REQ-MOD-UI-DIALOG, REQ-MOD-UI-PREVIEW,
|
||||
// REQ-MOD-UI-AUTO-DIALOG).
|
||||
const ShipDef* findLayoutShipDef(const std::string& id) const
|
||||
{
|
||||
if (id.empty()) { return nullptr; }
|
||||
const ShipDef* def = findShipDef(id);
|
||||
if (!def || def->layout.empty()) { return nullptr; }
|
||||
return def;
|
||||
}
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user