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;
|
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(listener);
|
||||||
assert(not contains(m_modification_listeners, listener));
|
assert(not contains(m_modification_listeners, listener));
|
||||||
m_modification_listeners.push_back(listener);
|
m_modification_listeners.push_back(listener);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Buffer::unregister_modification_listener(BufferModificationListener* listener) const
|
void Buffer::unregister_modification_listener(BufferModificationListener* listener)
|
||||||
{
|
{
|
||||||
assert(listener);
|
assert(listener);
|
||||||
auto it = std::find(m_modification_listeners.begin(),
|
auto it = std::find(m_modification_listeners.begin(),
|
||||||
|
|
|
@ -146,8 +146,8 @@ public:
|
||||||
Type type() const { return m_type; }
|
Type type() const { return m_type; }
|
||||||
void notify_saved();
|
void notify_saved();
|
||||||
|
|
||||||
void register_modification_listener(BufferModificationListener* listener) const;
|
void register_modification_listener(BufferModificationListener* listener);
|
||||||
void unregister_modification_listener(BufferModificationListener* listener) const;
|
void unregister_modification_listener(BufferModificationListener* listener);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
BufferChar at(BufferPos position) const;
|
BufferChar at(BufferPos position) const;
|
||||||
|
@ -180,7 +180,7 @@ private:
|
||||||
|
|
||||||
size_t m_last_save_undo_index;
|
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()
|
void DynamicBufferIterator::register_ifp()
|
||||||
{
|
{
|
||||||
if (is_valid())
|
if (is_valid())
|
||||||
buffer().register_modification_listener(this);
|
const_cast<Buffer&>(buffer()).register_modification_listener(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
void DynamicBufferIterator::unregister_ifn()
|
void DynamicBufferIterator::unregister_ifn()
|
||||||
{
|
{
|
||||||
if (is_valid())
|
if (is_valid())
|
||||||
buffer().unregister_modification_listener(this);
|
const_cast<Buffer&>(buffer()).unregister_modification_listener(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue
Block a user