[gnote] Do not use singleton IGnote in NoteBuffer



commit 213b0cbde4e8ccf522b9250a5d2072ba07ed7aac
Author: Aurimas Černius <aurisc4 gmail com>
Date:   Sat Dec 7 22:56:01 2019 +0200

    Do not use singleton IGnote in NoteBuffer

 src/note.cpp       | 2 +-
 src/notebuffer.cpp | 6 +++---
 src/notebuffer.hpp | 8 +++++---
 3 files changed, 9 insertions(+), 7 deletions(-)
---
diff --git a/src/note.cpp b/src/note.cpp
index d9a512aa..e2ede68d 100644
--- a/src/note.cpp
+++ b/src/note.cpp
@@ -711,7 +711,7 @@ namespace gnote {
   {
     if(!m_buffer) {
       DBG_OUT("Creating buffer for %s", m_data.data().title().c_str());
-      m_buffer = NoteBuffer::create(get_tag_table(), *this);
+      m_buffer = NoteBuffer::create(get_tag_table(), *this, IGnote::obj().preferences());
       m_data.set_buffer(m_buffer);
 
       m_buffer->signal_changed().connect(
diff --git a/src/notebuffer.cpp b/src/notebuffer.cpp
index f3d03f62..52ccf631 100644
--- a/src/notebuffer.cpp
+++ b/src/notebuffer.cpp
@@ -28,7 +28,6 @@
 
 #include "config.h"
 #include "debug.hpp"
-#include "ignote.hpp"
 #include "notebuffer.hpp"
 #include "notetag.hpp"
 #include "note.hpp"
@@ -56,15 +55,16 @@ namespace gnote {
 
   bool NoteBuffer::get_enable_auto_bulleted_lists() const
   {
-    return IGnote::obj().preferences().get_schema_settings(Preferences::SCHEMA_GNOTE)->get_boolean(
+    return m_preferences.get_schema_settings(Preferences::SCHEMA_GNOTE)->get_boolean(
         Preferences::ENABLE_AUTO_BULLETED_LISTS);
   }
   
 
-  NoteBuffer::NoteBuffer(const NoteTagTable::Ptr & tags, Note & note_)
+  NoteBuffer::NoteBuffer(const NoteTagTable::Ptr & tags, Note & note_, Preferences & preferences)
     : Gtk::TextBuffer(tags)
     , m_undomanager(NULL)
     , m_note(note_)
+    , m_preferences(preferences)
   {
     m_undomanager = new UndoManager(this);
     signal_insert().connect(sigc::mem_fun(*this, &NoteBuffer::text_insert_event));
diff --git a/src/notebuffer.hpp b/src/notebuffer.hpp
index 07fbcf7e..b59f81e8 100644
--- a/src/notebuffer.hpp
+++ b/src/notebuffer.hpp
@@ -40,6 +40,7 @@ namespace sharp {
 
 namespace gnote {
 
+  class Preferences;
   class Note;
   class UndoManager;
 
@@ -53,9 +54,9 @@ public:
   typedef sigc::signal<void, int, bool> ChangeDepthHandler;
 
   bool get_enable_auto_bulleted_lists() const;
-  static Ptr create(const NoteTagTable::Ptr & table, Note & note)
+  static Ptr create(const NoteTagTable::Ptr & table, Note & note, Preferences & preferences)
     {
-      return Ptr(new NoteBuffer(table, note));
+      return Ptr(new NoteBuffer(table, note, preferences));
     }
   ~NoteBuffer();
 
@@ -115,7 +116,7 @@ public:
   static bool is_bullet(gunichar c);
   void select_note_body();
 protected: 
-  NoteBuffer(const NoteTagTable::Ptr &, Note &);
+  NoteBuffer(const NoteTagTable::Ptr &, Note &, Preferences &);
 
   virtual void on_apply_tag(const Glib::RefPtr<Gtk::TextTag> & tag,
                        const Gtk::TextIter &,  const Gtk::TextIter &) override;
@@ -153,6 +154,7 @@ private:
 
   // The note that owns this buffer
   Note &                       m_note;
+  Preferences &                m_preferences;
 };
 
 class NoteBufferArchiver


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