[gnote] Fix a bug where after import from Tomboy the titles wouldn't look like titles.



commit 96b007c5ccb5a316a3f491f0151eaf241f0aa40b
Author: Hubert Figuiere <hub figuiere net>
Date:   Mon Jun 22 03:20:59 2009 -0400

    Fix a bug where after import from Tomboy the titles wouldn't look like titles.
    
    Split the load to have a post_load()
    Also ensure to no load the addins twice for a note.

 src/addinmanager.cpp |    4 ++++
 src/notemanager.cpp  |   35 ++++++++++++++++++++---------------
 src/notemanager.hpp  |    1 +
 3 files changed, 25 insertions(+), 15 deletions(-)
---
diff --git a/src/addinmanager.cpp b/src/addinmanager.cpp
index 4392345..01c86d0 100644
--- a/src/addinmanager.cpp
+++ b/src/addinmanager.cpp
@@ -149,6 +149,10 @@ namespace gnote {
 
   void AddinManager::load_addins_for_note(const Note::Ptr & note)
   {
+    if(m_note_addins.find(note) != m_note_addins.end()) {
+      ERR_OUT("trying to load addins when they are already loaded");
+      return;
+    }
     std::list<NoteAddin *> loaded_addins;
     m_note_addins[note] = loaded_addins;
 
diff --git a/src/notemanager.cpp b/src/notemanager.cpp
index 7f837c2..42e2830 100644
--- a/src/notemanager.cpp
+++ b/src/notemanager.cpp
@@ -136,6 +136,8 @@ namespace gnote {
           has_imported |= (*iter)->first_run(*this);
         }
       }
+      // we MUST call this after import
+      post_load();
 
       // First run. Create "Start Here" notes.
       create_start_notes ();
@@ -310,7 +312,24 @@ namespace gnote {
                 file_path.c_str(), e.what());
       }
     }
-      
+    post_load();
+    // Make sure that a Start Note Uri is set in the preferences, and
+    // make sure that the Uri is valid to prevent bug #508982. This
+    // has to be done here for long-time Tomboy users who won't go
+    // through the create_start_notes () process.
+    if (start_note_uri().empty() ||
+        !find_by_uri(start_note_uri())) {
+      // Attempt to find an existing Start Here note
+      Note::Ptr start_note = find (_("Start Here"));
+      if (start_note) {
+        Preferences::obj().set<std::string>(Preferences::START_NOTE_URI, start_note->uri());
+      }
+    }
+  }
+
+
+  void NoteManager::post_load()
+  {
     m_notes.sort (boost::bind(&compare_dates, _1, _2));
 
     // Update the trie so addins can access it, if they want.
@@ -338,20 +357,6 @@ namespace gnote {
         note->queue_save (Note::NO_CHANGE);
       }
     }
-
-    // Make sure that a Start Note Uri is set in the preferences, and
-    // make sure that the Uri is valid to prevent bug #508982. This
-    // has to be done here for long-time Tomboy users who won't go
-    // through the create_start_notes () process.
-    if (start_note_uri().empty() ||
-        !find_by_uri(start_note_uri())) {
-      // Attempt to find an existing Start Here note
-      Note::Ptr start_note = find (_("Start Here"));
-      if (start_note) {
-        Preferences::obj().set<std::string>(Preferences::START_NOTE_URI, start_note->uri());
-      }
-    }
-    
   }
 
   bool NoteManager::on_exiting_event()
diff --git a/src/notemanager.hpp b/src/notemanager.hpp
index 57dfe88..bcc1bee 100644
--- a/src/notemanager.hpp
+++ b/src/notemanager.hpp
@@ -108,6 +108,7 @@ namespace gnote {
     void create_start_notes();
     void on_note_save(const Note::Ptr & note);
     void load_notes();
+    void post_load();
     bool first_run() const;
     void create_notes_dir() const;
     bool on_exiting_event();



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