calculator/src
Michał Janiszewski 60c5c39ee5 Fix #563: Odd dependency cycle (#570)
There is an odd dependency in CalcEngine.

`CalculatorManager` inherits `ICalcDisplay` and implements a set of virtual calls it exposes, in particular `SetPrimaryDisplay`.
2517854836/src/CalcManager/Header%20Files/ICalcDisplay.h (L13)

When setting a mode in `CalculatorManager`, e.g. 2517854836/src/CalcManager/CalculatorManager.cpp (L208)
`this` (here: an instance of `CalculatorManager`) gets passed as an argument to the newly created `CCalcEngine` as `ICalcDisplay` pointer and the engine is stored as `unique_ptr` member field of `CalculatorManager`.

In the destructor of `CalculatorManager`, a single function is called, `MemorizedNumberClearAll` which then invokes `ProcessCommand(IDC_MCLEAR)` on current engine, gets passed on to `CCalcEngine::ProcessCommandWorker`, to `DisplayNum`, to `CCalcEngine::SetPrimaryDisplay` and finally to `m_pCalcDisplay->SetPrimaryDisplay`, but here `m_pCalcDisplay` _was_ the instance of `CalculatorManager` that just got its destructor called.

2517854836/src/CalcManager/CalculatorManager.cpp (L46)
2517854836/src/CalcManager/CalculatorManager.cpp (L475)
2517854836/src/CalcManager/CEngine/scicomm.cpp (L87)
2517854836/src/CalcManager/CEngine/scicomm.cpp (L133)
2517854836/src/CalcManager/CEngine/scidisp.cpp (L124)
2517854836/src/CalcManager/CEngine/scicomm.cpp (L837)

It will likely differ by implementation on how exactly, but the [standard suggests](http://eel.is/c++draft/class.cdtor#4) that will invoke the pure virtual `ICalcDisplay::SetPrimaryDisplay`. In case of GCC I believe the vtable is already destroyed by the time you enter dtor's body.

There appears to be no reason to call `MemorizedNumberClearAll` in `CalculatorManager::~CalculatorManager()` because the calc manager and all its engines are going down anyway.  Therefore, removing the call (and thus, the destructor which would then be empty).


Fixes #563: Odd dependency cycle
2019-07-25 23:24:12 -07:00
..
build Hello GitHub 2019-01-28 16:24:37 -08:00
CalcManager Fix #563: Odd dependency cycle (#570) 2019-07-25 23:24:12 -07:00
Calculator Modifying the title of the window to "Calculator [Dev]" (#531) 2019-07-25 23:02:37 -07:00
CalculatorUITestFramework UI tests should be able to test both dev and store-released builds (#567) 2019-06-25 11:29:32 -07:00
CalculatorUITests UI tests should be able to test both dev and store-released builds (#567) 2019-06-25 11:29:32 -07:00
CalculatorUnitTests Updated Calculator diagnostic data collection per the specification (#572) 2019-07-17 18:09:39 -07:00
CalcViewModel Added Input pasted event and added to all modes (#593) 2019-07-18 11:21:35 -07:00
Calculator.sln Update to v142 build tools for Visual Studio 2019 (#548) 2019-06-24 16:38:45 -07:00
CMakeLists.txt Add CMake project, GCC support (#540) 2019-06-06 14:08:31 -07:00
nuget.config updating nuget.org source to point to V3 (#129) 2019-03-07 07:33:22 -08:00
Settings.XamlStyler Hello GitHub 2019-01-28 16:24:37 -08:00