From 66fe2d84daa1ec72c2eb1385b1d8da705277403e Mon Sep 17 00:00:00 2001 From: Maxime Coste Date: Sun, 11 Feb 2018 13:06:19 +1100 Subject: Refuse modification of ReadOnly buffers and make Debug buffer readonly The debug buffer is a bit special as lots of events might mutate it, permitting it to be modified leads to some buggy behaviour: For example, `pipe` uses a ForwardChangeTracker to track buffer changes, but when applied on a debug buffer with the profile flag on, each shell execution will trigger an additional modification of the buffer while applying the changes, leading to an assertion failing as changes might not be happening in a forward way anymore. Trying to modify a debug buffer will now raise an error immediatly. --- src/buffer.hh | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) (limited to 'src/buffer.hh') diff --git a/src/buffer.hh b/src/buffer.hh index 0eb6a4f4..d8f18015 100644 --- a/src/buffer.hh +++ b/src/buffer.hh @@ -139,9 +139,9 @@ public: void set_fs_timestamp(timespec ts); void commit_undo_group(); - bool undo(size_t count = 1) noexcept; - bool redo(size_t count = 1) noexcept; - bool move_to(size_t history_id) noexcept; + bool undo(size_t count = 1); + bool redo(size_t count = 1); + bool move_to(size_t history_id); size_t current_history_id() const noexcept; size_t next_history_id() const noexcept { return m_next_history_id; } @@ -218,6 +218,7 @@ public: void on_registered(); void on_unregistered(); + void throw_if_read_only() const; private: void on_option_changed(const Option& option) override; @@ -272,7 +273,7 @@ private: SafePtr m_last_save_history_cursor; UndoGroup m_current_undo_group; - void move_to(HistoryNode* history_node) noexcept; + void move_to(HistoryNode* history_node); template HistoryNode* find_history_node(HistoryNode* node, const Func& func); -- cgit v1.2.3