DynamicBufferIterator: use const_cast instead of having a mutable field in Buffer
This commit is contained in:
parent
46a01b5a0b
commit
51ee0b61f4
|
@ -249,14 +249,14 @@ void Buffer::notify_saved()
|
|||
m_last_save_undo_index = history_cursor_index;
|
||||
}
|
||||
|
||||
void Buffer::register_modification_listener(BufferModificationListener* listener) const
|
||||
void Buffer::register_modification_listener(BufferModificationListener* listener)
|
||||
{
|
||||
assert(listener);
|
||||
assert(not contains(m_modification_listeners, listener));
|
||||
m_modification_listeners.push_back(listener);
|
||||
}
|
||||
|
||||
void Buffer::unregister_modification_listener(BufferModificationListener* listener) const
|
||||
void Buffer::unregister_modification_listener(BufferModificationListener* listener)
|
||||
{
|
||||
assert(listener);
|
||||
auto it = std::find(m_modification_listeners.begin(),
|
||||
|
|
|
@ -146,8 +146,8 @@ public:
|
|||
Type type() const { return m_type; }
|
||||
void notify_saved();
|
||||
|
||||
void register_modification_listener(BufferModificationListener* listener) const;
|
||||
void unregister_modification_listener(BufferModificationListener* listener) const;
|
||||
void register_modification_listener(BufferModificationListener* listener);
|
||||
void unregister_modification_listener(BufferModificationListener* listener);
|
||||
|
||||
private:
|
||||
BufferChar at(BufferPos position) const;
|
||||
|
@ -180,7 +180,7 @@ private:
|
|||
|
||||
size_t m_last_save_undo_index;
|
||||
|
||||
mutable std::vector<BufferModificationListener*> m_modification_listeners;
|
||||
std::vector<BufferModificationListener*> m_modification_listeners;
|
||||
};
|
||||
|
||||
}
|
||||
|
|
|
@ -59,13 +59,13 @@ void DynamicBufferIterator::on_modification(const BufferModification& modificati
|
|||
void DynamicBufferIterator::register_ifp()
|
||||
{
|
||||
if (is_valid())
|
||||
buffer().register_modification_listener(this);
|
||||
const_cast<Buffer&>(buffer()).register_modification_listener(this);
|
||||
}
|
||||
|
||||
void DynamicBufferIterator::unregister_ifn()
|
||||
{
|
||||
if (is_valid())
|
||||
buffer().unregister_modification_listener(this);
|
||||
const_cast<Buffer&>(buffer()).unregister_modification_listener(this);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue
Block a user