← Back to team overview

kicad-developers team mailing list archive

Re: Mocking Kiway

 

Hello again,

You may find it all noob questions, but I have to ask. I finally managed to mock Kiway object, but I noticed that next to virtual member functions it has non-virtual destructor. Wouldn't it cause memory leaks and other issues during deleting objects? This looks like a bug to me.

Regards,
Sylwester

On 07/04/2020 20:26, Sylwester Kocjan wrote:
Hello,

I try to prepare a test where SIM_PLOT_FRAME() will be used. Constructor of this frame requires Kiway, and I stumbled upon a problem I cannot solve on my own. Could you please answer answer to my questions, so I could move on?

1. There is a Kiway object used in mocks_eeschema.cpp, in PGM_MOCK_EESCHEMA_FRAME::OnPgmExit(). Code compiles fine. 2. I try to use Kiway in test_sch_sheet.cpp, but linking fails (undefined reference to KIWAY Kiway object). 3. It gets linked again when Kiway will be defined in test_sch_sheet.cpp (can be added in mocks_eeschema.cpp as well).

Diff with my changes is attached.

My questions are following:
- why linker doesn't complain in mocks_eeschema.cpp but does in test_sch_sheet.cpp? - why Pgm() or Kiface() can be accessed using function (therefore it is easy to mock them), and Kiway is a static object?

Best regards,
Sylwester



References