[gnote] Do not statically access Gnote from command line



commit 35e373a60cd69e0d6fe04eb2b97ef590754cd262
Author: Aurimas Černius <aurisc4 gmail com>
Date:   Fri Nov 1 23:41:08 2019 +0200

    Do not statically access Gnote from command line

 src/gnote.cpp | 8 +++++---
 src/gnote.hpp | 3 ++-
 2 files changed, 7 insertions(+), 4 deletions(-)
---
diff --git a/src/gnote.cpp b/src/gnote.cpp
index de28a207..791a8b65 100644
--- a/src/gnote.cpp
+++ b/src/gnote.cpp
@@ -63,6 +63,7 @@ namespace gnote {
     , m_is_background(false)
     , m_is_shell_search(false)
     , m_prefsdlg(NULL)
+    , m_cmd_line(*this)
   {
   }
 
@@ -114,7 +115,7 @@ namespace gnote {
     Gtk::Application::on_command_line(command_line);
     int argc = 0;
     char **argv = command_line->get_arguments(argc);
-    GnoteCommandLine passed_cmd_line;
+    GnoteCommandLine passed_cmd_line(*this);
     GnoteCommandLine &cmdline = m_manager ? passed_cmd_line : m_cmd_line;
     cmdline.parse(argc, argv);
     m_is_background = cmdline.background();
@@ -498,8 +499,9 @@ namespace gnote {
   }
 
 
-  GnoteCommandLine::GnoteCommandLine()
+  GnoteCommandLine::GnoteCommandLine(IGnote & ignote)
     : m_context(g_option_context_new("Foobar"))
+    , m_gnote(ignote)
     , m_manager(NULL)
     , m_use_panel(false)
     , m_background(false)
@@ -608,7 +610,7 @@ namespace gnote {
       else {
         execute(remote);
       }
-      static_cast<Gnote&>(Gnote::obj()).quit();
+      static_cast<Gnote&>(m_gnote).quit();
     }
     return 0;
   }
diff --git a/src/gnote.hpp b/src/gnote.hpp
index 9bfbc115..60f17fcf 100644
--- a/src/gnote.hpp
+++ b/src/gnote.hpp
@@ -46,7 +46,7 @@ class RemoteControlClient;
 class GnoteCommandLine
 {
 public:
-  GnoteCommandLine();
+  GnoteCommandLine(IGnote & ignote);
   ~GnoteCommandLine();
   void set_note_manager(NoteManagerBase & manager)
     {
@@ -84,6 +84,7 @@ private:
 
   GOptionContext *m_context;
 
+  IGnote    & m_gnote;
   NoteManagerBase *m_manager;
   bool        m_use_panel;
   bool        m_background;


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