Opened 8 years ago

Last modified 3 years ago

#4260 new defect

CCmpSelectable.cpp unit test for buildings without footprint

Reported by: elexis Owned by:
Priority: If Time Permits Milestone: Backlog
Component: Simulation Keywords: simple
Cc: Patch:

Description (last modified by Mohamed Moanis)

Reproduce: remove <Footprint> from binaries/data/mods/public/simulation/templates/template_structure_civic_civil_centre.xml and start a game, select the cc.

Stack:

0x000000000052ab6d in CCmpSelectable::RenderSubmit (collector=..., this=0x526b460)
    at ../../../source/simulation2/components/CCmpSelectable.cpp:629
629						m_BuildingOverlay->m_Color = m_Color; // done separately so alpha changes don't require a full update call

The cpp component shouldn't crash in such a case but detect the missing footprint component when trying to access it, show an error message and exit gracefully.

Furthermore the GetSchema() should be extended to require Footprint.

Change History (9)

comment:1 by Mohamed Moanis, 7 years ago

Description: modified (diff)

Can I own this ticket. I already fixed the crash and can submit a patch for review. I just have 1 question about the change in the schema; do you mean the schema in the CCmpSelectable class, should contain require Footprint?

comment:2 by elexis, 7 years ago

Yes, because Selectable means showing a selection ring and that is scaled according to the footprint

comment:3 by elexis, 7 years ago

Actually nevermind what I said. We can't require other components.

comment:4 by Mohamed Moanis, 7 years ago

The problem can't be reproduced on master-branch. It appears to be solved indirectly by #4349 (https://code.wildfiregames.com/D238)

in reply to:  4 comment:5 by Itms, 7 years ago

Even if the crash disappeared, it would be great to have your patch! You can take a look at SubmittingPatches.

You could even look into adding a unit test so we make sure we don't stumble into the issue again :)

comment:6 by elexis, 7 years ago

Priority: Should HaveIf Time Permits
Summary: CCmpSelectable.cpp segfaults when selecting a building without footprintCCmpSelectable.cpp unit test for buildings without footprint

There is only one reference to m_BuildingOverlay in this file and that has a check for initialization added with the commit mentioned above: https://code.wildfiregames.com/rP19519#inline-398

But a unit test could be written that just creates such a component without creating a footprint component and tests whether it crashes or not.

Such a fle would have to be added to source/simulation2/components/tests/test_Selectable.h.

comment:7 by Imarok, 5 years ago

Component: UI & SimulationSimulation

Move tickets to Simulation as UI & Simulation got some sub components.

comment:8 by Silier, 3 years ago

Keywords: simple removed
severity: simple

comment:9 by Silier, 3 years ago

Keywords: simple added
Note: See TracTickets for help on using tickets.