[gnote] Do not use singleton IGnote in search provider



commit 33a171a1bd1bb6be8961cc140682d944f178b4f6
Author: Aurimas Černius <aurisc4 gmail com>
Date:   Sun Nov 17 18:44:20 2019 +0200

    Do not use singleton IGnote in search provider

 src/dbus/searchprovider.cpp | 7 ++++---
 src/dbus/searchprovider.hpp | 3 ++-
 src/remotecontrolproxy.cpp  | 2 +-
 3 files changed, 7 insertions(+), 5 deletions(-)
---
diff --git a/src/dbus/searchprovider.cpp b/src/dbus/searchprovider.cpp
index 5970e791..f7e23e9a 100644
--- a/src/dbus/searchprovider.cpp
+++ b/src/dbus/searchprovider.cpp
@@ -37,8 +37,9 @@ namespace Gnote {
 SearchProvider::SearchProvider(const Glib::RefPtr<Gio::DBus::Connection> & conn,
                                const char *object_path,
                                const Glib::RefPtr<Gio::DBus::InterfaceInfo> & search_interface,
-                               gnote::NoteManagerBase & manager)
+                               gnote::IGnote & g, gnote::NoteManagerBase & manager)
   : Gio::DBus::InterfaceVTable(sigc::mem_fun(*this, &SearchProvider::on_method_call))
+  , m_gnote(g)
   , m_manager(manager)
 {
   conn->register_object(object_path, search_interface, *this);
@@ -204,7 +205,7 @@ void SearchProvider::ActivateResult(const Glib::ustring & identifier,
 {
   gnote::NoteBase::Ptr note = m_manager.find_by_uri(identifier);
   if(note != 0) {
-    gnote::IGnote::obj().open_note(std::static_pointer_cast<gnote::Note>(note));
+    m_gnote.open_note(std::static_pointer_cast<gnote::Note>(note));
   }
 }
 
@@ -233,7 +234,7 @@ Glib::VariantContainerBase SearchProvider::LaunchSearch_stub(const Glib::Variant
 gchar *SearchProvider::get_icon()
 {
   if(!m_note_icon) {
-    Gtk::IconInfo info = gnote::IGnote::obj().icon_manager().lookup_icon(gnote::IconManager::NOTE, 48);
+    Gtk::IconInfo info = m_gnote.icon_manager().lookup_icon(gnote::IconManager::NOTE, 48);
     m_note_icon = Gio::Icon::create(info.get_filename());
   }
 
diff --git a/src/dbus/searchprovider.hpp b/src/dbus/searchprovider.hpp
index 39165dcf..d3337c3b 100644
--- a/src/dbus/searchprovider.hpp
+++ b/src/dbus/searchprovider.hpp
@@ -37,7 +37,7 @@ class SearchProvider
 public:
   SearchProvider(const Glib::RefPtr<Gio::DBus::Connection> & conn, const char *object_path,
                  const Glib::RefPtr<Gio::DBus::InterfaceInfo> & search_interface,
-                 gnote::NoteManagerBase & manager);
+                 gnote::IGnote & g, gnote::NoteManagerBase & manager);
 
   std::vector<Glib::ustring> GetInitialResultSet(const std::vector<Glib::ustring> & terms);
   std::vector<Glib::ustring> GetSubsearchResultSet(const std::vector<Glib::ustring> & previous_results,
@@ -64,6 +64,7 @@ private:
   typedef Glib::VariantContainerBase (SearchProvider::*stub_func)(const Glib::VariantContainerBase &);
   std::map<Glib::ustring, stub_func> m_stubs;
 
+  gnote::IGnote & m_gnote;
   gnote::NoteManagerBase & m_manager;
   Glib::RefPtr<Gio::Icon> m_note_icon;
 };
diff --git a/src/remotecontrolproxy.cpp b/src/remotecontrolproxy.cpp
index dfc32208..eb65a36a 100644
--- a/src/remotecontrolproxy.cpp
+++ b/src/remotecontrolproxy.cpp
@@ -128,7 +128,7 @@ void RemoteControlProxy::register_object(const Glib::RefPtr<Gio::DBus::Connectio
   load_introspection_xml();
   m_remote_control = new RemoteControl(conn, m_gnote, manager, GNOTE_SERVER_PATH, GNOTE_INTERFACE_NAME, 
m_gnote_interface);
   m_search_provider = new org::gnome::Gnote::SearchProvider(conn, GNOTE_SEARCH_PROVIDER_PATH,
-                                                            m_search_provider_interface, manager);
+                                                            m_search_provider_interface, m_gnote, manager);
   on_finish(true, true);
 }
 


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