diff options
Diffstat (limited to 'src/server/UndoStack.hpp')
-rw-r--r-- | src/server/UndoStack.hpp | 34 |
1 files changed, 19 insertions, 15 deletions
diff --git a/src/server/UndoStack.hpp b/src/server/UndoStack.hpp index 04021b99..443497cc 100644 --- a/src/server/UndoStack.hpp +++ b/src/server/UndoStack.hpp @@ -17,12 +17,12 @@ #ifndef INGEN_ENGINE_UNDOSTACK_HPP #define INGEN_ENGINE_UNDOSTACK_HPP -#include "ingen/AtomSink.hpp" -#include "ingen/ingen.h" -#include "lv2/atom/atom.h" -#include "lv2/atom/util.h" -#include "serd/serd.h" -#include "sratom/sratom.h" +#include <ingen/AtomSink.hpp> +#include <lv2/atom/atom.h> +#include <lv2/atom/util.h> +#include <serd/serd.h> +#include <server.h> +#include <sratom/sratom.h> #include <cstdint> #include <cstdio> @@ -38,10 +38,12 @@ class URIs; namespace server { -class INGEN_API UndoStack : public AtomSink { +class INGEN_SERVER_API UndoStack : public AtomSink +{ public: struct Entry { - Entry(time_t time=0) : time(time) {} + explicit Entry(time_t t) noexcept : time{t} {} + Entry() noexcept : Entry{0} {} Entry(const Entry& copy) : time(copy.time) @@ -54,10 +56,12 @@ public: ~Entry() { clear(); } Entry& operator=(const Entry& rhs) { - clear(); - time = rhs.time; - for (const LV2_Atom* ev : rhs.events) { - push_event(ev); + if (&rhs != this) { + clear(); + time = rhs.time; + for (const LV2_Atom* ev : rhs.events) { + push_event(ev); + } } return *this; } @@ -71,7 +75,7 @@ public: void push_event(const LV2_Atom* ev) { const uint32_t size = lv2_atom_total_size(ev); - LV2_Atom* copy = (LV2_Atom*)malloc(size); + auto* copy = static_cast<LV2_Atom*>(malloc(size)); memcpy(copy, ev, size); events.push_front(copy); } @@ -80,7 +84,7 @@ public: std::deque<LV2_Atom*> events; }; - UndoStack(URIs& uris, URIMap& map) : _uris(uris), _map(map), _depth(0) {} + UndoStack(URIs& uris, URIMap& map) noexcept : _uris(uris), _map(map) {} int start_entry(); bool write(const LV2_Atom* msg, int32_t default_id=0) override; @@ -103,7 +107,7 @@ private: URIs& _uris; URIMap& _map; std::deque<Entry> _stack; - int _depth; + int _depth{0}; }; } // namespace server |