[gnote] Fix crash when closing after multiple link activations



commit b64edeb10b01a9787e52593d63a76c0f9cdf5033
Author: Aurimas Černius <aurisc4 gmail com>
Date:   Tue Jun 18 23:18:21 2013 +0300

    Fix crash when closing after multiple link activations
    
    Activating same link twice causes errors in console, while activating
    three or more times causes segfaults.

 src/notetag.cpp  |    6 +++---
 src/notetag.hpp  |    8 ++++----
 src/watchers.cpp |    7 +++----
 src/watchers.hpp |    5 ++---
 4 files changed, 12 insertions(+), 14 deletions(-)
---
diff --git a/src/notetag.cpp b/src/notetag.cpp
index 1863dfc..8629af4 100644
--- a/src/notetag.cpp
+++ b/src/notetag.cpp
@@ -130,7 +130,7 @@ namespace gnote {
   void NoteTag::get_extents(const Gtk::TextIter & iter, Gtk::TextIter & start,
                             Gtk::TextIter & end)
   {
-    Glib::RefPtr<Gtk::TextTag> this_ref(this);
+    Glib::RefPtr<Gtk::TextTag> this_ref = NoteTagTable::instance()->lookup(property_name());
     start = iter;
     if (!start.begins_tag (this_ref)) {
       start.backward_to_tag_toggle (this_ref);
@@ -255,7 +255,7 @@ namespace gnote {
       }
     }
 #endif
-    retval = m_signal_activate(NoteTag::Ptr(this), editor, start, end);
+    retval = m_signal_activate(editor, start, end);
 
     return retval;
   }
@@ -290,7 +290,7 @@ namespace gnote {
     m_widget = value;
 
     try {
-      m_signal_changed(Glib::RefPtr<Gtk::TextTag>(this), false);
+      m_signal_changed(*this, false);
     } catch (sharp::Exception & e) {
       DBG_OUT("Exception calling TagChanged from NoteTag.set_Widget: %s", e.what());
     }
diff --git a/src/notetag.hpp b/src/notetag.hpp
index e3137b9..c46e5b2 100644
--- a/src/notetag.hpp
+++ b/src/notetag.hpp
@@ -1,7 +1,7 @@
 /*
  * gnote
  *
- * Copyright (C) 2011 Aurimas Cernius
+ * Copyright (C) 2011,2013 Aurimas Cernius
  * Copyright (C) 2009 Hubert Figuiere
  *
  * This program is free software: you can redistribute it and/or modify
@@ -64,7 +64,7 @@ class NoteTag
 public:
   typedef Glib::RefPtr<NoteTag> Ptr;
   typedef Glib::RefPtr<const NoteTag> ConstPtr;
-  typedef sigc::signal<bool, const NoteTag::Ptr &, const NoteEditor &,
+  typedef sigc::signal<bool, const NoteEditor &,
                        const Gtk::TextIter &, const Gtk::TextIter &> TagActivatedHandler;
 
   enum TagFlags {
@@ -148,7 +148,7 @@ public:
     { 
       return m_signal_activate;
     }
-  sigc::signal<void,const Glib::RefPtr<Gtk::TextTag>&,bool> & signal_changed()
+  sigc::signal<void,const Gtk::TextTag&,bool> & signal_changed()
     { 
       return m_signal_changed;
     }
@@ -182,7 +182,7 @@ private:
   int                 m_flags;
   TagActivatedHandler m_signal_activate;
   ContrastPaletteColor m_palette_foreground;
-  sigc::signal<void,const Glib::RefPtr<Gtk::TextTag>&,bool> m_signal_changed;
+  sigc::signal<void,const Gtk::TextTag&,bool> m_signal_changed;
   TagSaveType         m_save_type;
 };
 
diff --git a/src/watchers.cpp b/src/watchers.cpp
index 2a6e0fd..3d92b89 100644
--- a/src/watchers.cpp
+++ b/src/watchers.cpp
@@ -478,7 +478,7 @@ namespace gnote {
   }
 
 
-  bool NoteUrlWatcher::on_url_tag_activated(const NoteTag::Ptr &, const NoteEditor &,
+  bool NoteUrlWatcher::on_url_tag_activated(const NoteEditor &,
                               const Gtk::TextIter & start, const Gtk::TextIter & end)
 
   {
@@ -607,7 +607,7 @@ namespace gnote {
     Gtk::TextIter start, end;
     m_url_tag->get_extents (click_iter, start, end);
 
-    on_url_tag_activated (m_url_tag, *(NoteEditor*)get_window()->editor(), start, end);
+    on_url_tag_activated(*(NoteEditor*)get_window()->editor(), start, end);
   }
 
 
@@ -645,7 +645,6 @@ namespace gnote {
     m_on_note_renamed_cid = manager().signal_note_renamed.connect(
       sigc::mem_fun(*this, &NoteLinkWatcher::on_note_renamed));
 
-    m_url_tag = get_note()->get_tag_table()->get_url_tag();
     m_link_tag = get_note()->get_tag_table()->get_link_tag();
     m_broken_link_tag = get_note()->get_tag_table()->get_broken_link_tag();
   }
@@ -923,7 +922,7 @@ namespace gnote {
     return false;
   }
 
-  bool NoteLinkWatcher::on_link_tag_activated(const NoteTag::Ptr &, const NoteEditor & editor,
+  bool NoteLinkWatcher::on_link_tag_activated(const NoteEditor & editor,
                                               const Gtk::TextIter &start, 
                                               const Gtk::TextIter &end)
   {
diff --git a/src/watchers.hpp b/src/watchers.hpp
index 22608ee..3b45073 100644
--- a/src/watchers.hpp
+++ b/src/watchers.hpp
@@ -140,7 +140,7 @@ namespace gnote {
     NoteUrlWatcher();
   private:
     std::string get_url(const Gtk::TextIter & start, const Gtk::TextIter & end);
-    bool on_url_tag_activated(const NoteTag::Ptr &, const NoteEditor &,
+    bool on_url_tag_activated(const NoteEditor &,
                               const Gtk::TextIter &, const Gtk::TextIter &);
     void apply_url_to_block (Gtk::TextIter start, Gtk::TextIter end);
     void on_apply_tag(const Glib::RefPtr<Gtk::TextBuffer::Tag> & tag,
@@ -186,10 +186,9 @@ namespace gnote {
                       const Gtk::TextIter & start, const Gtk::TextIter &end);
 
     bool open_or_create_link(const NoteEditor &, const Gtk::TextIter &,const Gtk::TextIter &);
-    bool on_link_tag_activated(const NoteTag::Ptr &, const NoteEditor &,
+    bool on_link_tag_activated(const NoteEditor &,
                                const Gtk::TextIter &, const Gtk::TextIter &);
 
-    NoteTag::Ptr m_url_tag;
     NoteTag::Ptr m_link_tag;
     NoteTag::Ptr m_broken_link_tag;
 


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