From f2699a3f2b2f244e56be449dea008fa4cedc6bba Mon Sep 17 00:00:00 2001 From: Thomas Harte Date: Sun, 20 Aug 2017 10:24:01 -0400 Subject: [PATCH] Okay, even if releasing it is unsafe, I can at least move the typer so that it is no longer called. --- Machines/Typer.hpp | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/Machines/Typer.hpp b/Machines/Typer.hpp index 32cb25ce9..7e85ef4b7 100644 --- a/Machines/Typer.hpp +++ b/Machines/Typer.hpp @@ -107,12 +107,21 @@ class TypeRecipient: public Typer::Delegate { */ void typer_reset(Typer *typer) { clear_all_keys(); + + // It's unsafe to deallocate typer right now, since it is the caller, but also it has a small + // memory footprint and it's desireable not to imply that the subclass need call it any more. + // So shuffle it off into a siding. + previous_typer_ = std::move(typer_); + typer_ = nullptr; } protected: virtual HalfCycles get_typer_delay() { return HalfCycles(0); } virtual HalfCycles get_typer_frequency() { return HalfCycles(0); } std::unique_ptr typer_; + + private: + std::unique_ptr previous_typer_; }; }