[gnote] Do not use static IGnote in MainWindow::present_in_new_window



commit cae3751987035b90dd987be5132f359627110dc5
Author: Aurimas Černius <aurisc4 gmail com>
Date:   Tue Dec 3 22:18:39 2019 +0200

    Do not use static IGnote in MainWindow::present_in_new_window

 src/mainwindow.cpp                        | 4 ++--
 src/mainwindow.hpp                        | 3 ++-
 src/notebooks/notebooknewnotemenuitem.cpp | 2 +-
 src/recentchanges.cpp                     | 3 ++-
 src/recentchanges.hpp                     | 1 +
 5 files changed, 8 insertions(+), 5 deletions(-)
---
diff --git a/src/mainwindow.cpp b/src/mainwindow.cpp
index b0efa7a2..b5b99368 100644
--- a/src/mainwindow.cpp
+++ b/src/mainwindow.cpp
@@ -62,13 +62,13 @@ MainWindow *MainWindow::present_active(const Note::Ptr & note)
   return NULL;
 }
 
-MainWindow *MainWindow::present_in_new_window(const Note::Ptr & note, bool close_on_esc)
+MainWindow *MainWindow::present_in_new_window(IGnote & g, const Note::Ptr & note, bool close_on_esc)
 {
   if(!note) {
     return NULL;
   }
   if(!MainWindow::present_active(note)) {
-    MainWindow & window = IGnote::obj().new_main_window();
+    MainWindow & window = g.new_main_window();
     window.present_note(note);
     window.present();
     window.close_on_escape(close_on_esc);
diff --git a/src/mainwindow.hpp b/src/mainwindow.hpp
index 7e052723..69ed3e0e 100644
--- a/src/mainwindow.hpp
+++ b/src/mainwindow.hpp
@@ -27,6 +27,7 @@
 
 namespace gnote {
 
+class IGnote;
 class Preferences;
 
 class MainWindow
@@ -37,7 +38,7 @@ public:
   static MainWindow *get_owning(Gtk::Widget & widget);
   static void present_in(MainWindow & win, const Note::Ptr & note);
   static MainWindow *present_active(const Note::Ptr & note);
-  static MainWindow *present_in_new_window(const Note::Ptr & note, bool close_on_esacpe);
+  static MainWindow *present_in_new_window(IGnote & g, const Note::Ptr & note, bool close_on_esacpe);
   static MainWindow *present_default(const Note::Ptr & note);
   static bool use_client_side_decorations(Preferences & prefs);
 
diff --git a/src/notebooks/notebooknewnotemenuitem.cpp b/src/notebooks/notebooknewnotemenuitem.cpp
index 6544c500..04a6047f 100644
--- a/src/notebooks/notebooknewnotemenuitem.cpp
+++ b/src/notebooks/notebooknewnotemenuitem.cpp
@@ -55,7 +55,7 @@ namespace gnote {
       
       // Look for the template note and create a new note
       Note::Ptr note = m_notebook->create_notebook_note ();
-      MainWindow::present_in_new_window(note,
+      MainWindow::present_in_new_window(IGnote::obj(), note,
         IGnote::obj().preferences().get_schema_settings(Preferences::SCHEMA_GNOTE)->get_boolean(
           Preferences::ENABLE_CLOSE_NOTE_ON_ESCAPE));
     }
diff --git a/src/recentchanges.cpp b/src/recentchanges.cpp
index 5b63b9e5..1087f88c 100644
--- a/src/recentchanges.cpp
+++ b/src/recentchanges.cpp
@@ -50,6 +50,7 @@ namespace gnote {
 
   NoteRecentChanges::NoteRecentChanges(IGnote & g, NoteManagerBase & m)
     : MainWindow(_("Gnote"))
+    , m_gnote(g)
     , m_note_manager(m)
     , m_preferences(g.preferences())
     , m_search_notes_widget(g, m)
@@ -367,7 +368,7 @@ namespace gnote {
 
   void NoteRecentChanges::on_open_note_new_window(const Note::Ptr & note)
   {
-    present_in_new_window(note, m_close_note_on_escape);
+    present_in_new_window(m_gnote, note, m_close_note_on_escape);
   }
 
   void NoteRecentChanges::on_delete_note()
diff --git a/src/recentchanges.hpp b/src/recentchanges.hpp
index ac533ab5..6fe3ee55 100644
--- a/src/recentchanges.hpp
+++ b/src/recentchanges.hpp
@@ -95,6 +95,7 @@ private:
   void add_action(const MainWindowAction::Ptr & action);
   void on_popover_widgets_changed();
 
+  IGnote             &m_gnote;
   NoteManagerBase    &m_note_manager;
   Preferences        &m_preferences;
   Gtk::Widget        *m_header_bar;


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