Skip to content

QtFRED: Fix crash in Ship Initial Status dialog when editing multiple ships - #7880

Open
LuytenFS wants to merge 2 commits into
scp-fs2open:masterfrom
LuytenFS:qtfred-initial-status-multiedit-crash
Open

LuytenFS wants to merge 2 commits into
scp-fs2open:masterfrom
LuytenFS:qtfred-initial-status-multiedit-crash

Conversation

@LuytenFS

Copy link
Copy Markdown
Contributor

Fixes a segfault I've stumbled upon when clicking OK in the Ship Initial Status dialog with more than one ship selected.

Cause
ShipInitialStatusDialogModel::initializeData() only sets up _numDockPoints and _dockpointArray when editing a single ship. In multi-edit mode _numDockPoints was left uninitialized (garbage value) and _dockpointArray stayed null. apply() still called updateDockingInfo(), which then indexed the null array.

Changes

  • Give _numDockPoints (and _multiEdit) default initializers so the multi-edit state is well defined.
  • Skip updateDockingInfo() in apply() when editing multiple ships, since docking is only editable for a single ship.
  • Add a guard in updateDockingInfo() that returns early if there is no dock point data.

Testing

  • Select multiple ships, open Initial Status, click OK: no crash (previously SIGSEGV in updateDockingInfo).
  • Single ship with dock points: docking changes still apply as before.

Additionally I noticed a triple copy-paste where the shield and hull "blank field" checks tested vflag three times instead of hflag, sflag. I assumed that wasn't intentionally, so correct me on this one.

Here's the backtrace using GDB if its of any use:
backtrace.txt

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