From 7a0857515ad216325fc3021c7490df9d01a21c7c Mon Sep 17 00:00:00 2001 From: Robin Haberkorn Date: Sun, 16 Nov 2014 05:23:10 +0100 Subject: avoid saving interface instance in UndoTokenInfoUpdate by implementing its run() method later in interface.h --- src/interface.h | 35 ++++++++++++++++++++++------------- 1 file changed, 22 insertions(+), 13 deletions(-) (limited to 'src/interface.h') diff --git a/src/interface.h b/src/interface.h index f7bec85..bba761d 100644 --- a/src/interface.h +++ b/src/interface.h @@ -114,19 +114,19 @@ class Interface { template class UndoTokenInfoUpdate : public UndoToken { - /* FIXME: can be implement this in interface.cpp - avoid saving iface */ - Interface *iface; Type *obj; public: - UndoTokenInfoUpdate(Interface *_iface, Type *_obj) - : iface(_iface), obj(_obj) {} - - void - run(void) - { - iface->info_update(obj); - } + UndoTokenInfoUpdate(Type *_obj) + : obj(_obj) {} + + /* + * Implemented at bottom, so we can reference + * the singleton interface object. + * Alternative would be to do an extern explicit + * template instantiation. + */ + void run(void); }; public: @@ -176,7 +176,7 @@ public: inline void undo_info_update(Type *obj) { - undo.push(new UndoTokenInfoUpdate(this, obj)); + undo.push(new UndoTokenInfoUpdate(obj)); } /* NULL means to redraw the current cmdline if necessary */ @@ -222,8 +222,17 @@ public: #endif namespace SciTECO { - /* object defined in main.cpp */ - extern InterfaceCurrent interface; + +/* object defined in main.cpp */ +extern InterfaceCurrent interface; + +template +void +Interface::UndoTokenInfoUpdate::run(void) +{ + interface.info_update(obj); } +} /* namespace SciTECO */ + #endif -- cgit v1.2.3