[gnote/tabbed] Fix excessive saves due to rogue marks
- From: Aurimas Černius <aurimasc src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnote/tabbed] Fix excessive saves due to rogue marks
- Date: Fri, 10 Dec 2021 19:48:08 +0000 (UTC)
commit 7d93b00e4ccceb294bb3fc849c53aab97c585889
Author: Aurimas Černius <aurisc4 gmail com>
Date: Fri Dec 10 21:47:47 2021 +0200
Fix excessive saves due to rogue marks
src/note.cpp | 16 ++++++++++++----
1 file changed, 12 insertions(+), 4 deletions(-)
---
diff --git a/src/note.cpp b/src/note.cpp
index 9d9a7a06..e96cf480 100644
--- a/src/note.cpp
+++ b/src/note.cpp
@@ -391,6 +391,13 @@ namespace gnote {
void Note::on_buffer_mark_set(const Gtk::TextBuffer::iterator & iter,
const Glib::RefPtr<Gtk::TextBuffer::Mark> & insert)
{
+ auto buffer = get_buffer();
+ auto insert_mark = buffer->get_insert();
+ auto selection_mark = buffer->get_selection_bound();
+ if(!(insert == insert_mark || insert == selection_mark)) {
+ return;
+ }
+
Gtk::TextIter start, end;
if(m_buffer->get_selection_bounds(start, end)) {
m_data.data().set_cursor_position(start.get_offset());
@@ -399,16 +406,17 @@ namespace gnote {
else if(insert->get_name() == "insert") {
m_data.data().set_cursor_position(iter.get_offset());
}
- else {
- return;
- }
DBG_OUT("OnBufferSetMark queueing save");
queue_save(NO_CHANGE);
}
- void Note::on_buffer_mark_deleted(const Glib::RefPtr<Gtk::TextBuffer::Mark> &)
+ void Note::on_buffer_mark_deleted(const Glib::RefPtr<Gtk::TextBuffer::Mark> & mark)
{
+ if(mark != get_buffer()->get_selection_bound()) {
+ return;
+ }
+
Gtk::TextIter start, end;
if(m_data.data().selection_bound_position() != m_data.data().cursor_position()
&& !m_buffer->get_selection_bounds(start, end)) {
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]