aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/interface.h
diff options
context:
space:
mode:
authorRobin Haberkorn <robin.haberkorn@googlemail.com>2014-11-16 05:23:10 +0100
committerRobin Haberkorn <robin.haberkorn@googlemail.com>2014-11-16 23:34:24 +0100
commit7a0857515ad216325fc3021c7490df9d01a21c7c (patch)
tree9a07c08d07cbe55b4d9b3fc2585fe0ad8cfb340a /src/interface.h
parent0f413b09e6d23c881a5010caae0e0a3affceca3b (diff)
downloadsciteco-7a0857515ad216325fc3021c7490df9d01a21c7c.tar.gz
avoid saving interface instance in UndoTokenInfoUpdate by implementing its run() method later in interface.h
Diffstat (limited to 'src/interface.h')
-rw-r--r--src/interface.h35
1 files changed, 22 insertions, 13 deletions
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 Type>
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<Type>(this, obj));
+ undo.push(new UndoTokenInfoUpdate<Type>(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 <class Type>
+void
+Interface::UndoTokenInfoUpdate<Type>::run(void)
+{
+ interface.info_update(obj);
}
+} /* namespace SciTECO */
+
#endif