[gnote] Fix crash when closing window with open note containing selection



commit c09b668a87e251e60caab752e05b08829fccc9f3
Author: Aurimas Černius <aurisc4 gmail com>
Date:   Thu May 6 23:20:16 2021 +0300

    Fix crash when closing window with open note containing selection

 src/notewindow.cpp | 13 ++++---------
 src/notewindow.hpp |  1 -
 2 files changed, 4 insertions(+), 10 deletions(-)
---
diff --git a/src/notewindow.cpp b/src/notewindow.cpp
index 0a40b8d4..9702d955 100644
--- a/src/notewindow.cpp
+++ b/src/notewindow.cpp
@@ -113,9 +113,6 @@ namespace gnote {
     m_editor->signal_populate_popup().connect(sigc::mem_fun(*this, &NoteWindow::on_populate_popup));
     m_editor->show();
 
-    // Sensitize the Link toolbar button on text selection
-    m_mark_set_timeout = new utils::InterruptableTimeout();
-    m_mark_set_timeout->signal_timeout.connect(sigc::mem_fun(*m_text_menu, &NoteTextMenu::refresh_state));
     note.get_buffer()->signal_mark_set().connect(
       sigc::mem_fun(*this, &NoteWindow::on_selection_mark_set));
 
@@ -141,8 +138,6 @@ namespace gnote {
   {
     delete m_global_keys;
     m_global_keys = NULL;
-    delete m_mark_set_timeout;
-    m_mark_set_timeout = NULL;
     // make sure editor is NULL. See bug 586084
     m_editor = NULL;
   }
@@ -350,11 +345,11 @@ namespace gnote {
     noteutils::show_deletion_dialog(single_note_list, dynamic_cast<Gtk::Window*>(host()));
   }
 
-  void NoteWindow::on_selection_mark_set(const Gtk::TextIter&, const Glib::RefPtr<Gtk::TextMark>&)
+  void NoteWindow::on_selection_mark_set(const Gtk::TextIter&, const Glib::RefPtr<Gtk::TextMark> & mark)
   {
-    // FIXME: Process in a timeout due to GTK+ bug #172050.
-    if(m_mark_set_timeout) {
-      m_mark_set_timeout->reset(0);
+    auto mark_name = mark->get_name();
+    if(mark_name == "insert" || mark_name == "selection_bound") {
+      m_text_menu->refresh_state();
     }
   }
 
diff --git a/src/notewindow.hpp b/src/notewindow.hpp
index fedf75d9..9a98924b 100644
--- a/src/notewindow.hpp
+++ b/src/notewindow.hpp
@@ -256,7 +256,6 @@ private:
   Gtk::CheckButton             *m_save_title_check_button;
 
   utils::GlobalKeybinder       *m_global_keys;
-  utils::InterruptableTimeout  *m_mark_set_timeout;
   bool                         m_enabled;
 
   Tag::Ptr m_template_tag;


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]