[PATCH 5/7] Only initialize/shutdown built-in or enabled application add-ins.



Signed-off-by: Łukasz Krotowski <lukasz krotowski gmail com>
---
 src/addinmanager.cpp        |   10 ++++++++--
 src/sharp/modulemanager.cpp |    9 +++++++++
 src/sharp/modulemanager.hpp |    1 +
 3 files changed, 18 insertions(+), 2 deletions(-)

diff --git a/src/addinmanager.cpp b/src/addinmanager.cpp
index 9a50ac2..28e8111 100644
--- a/src/addinmanager.cpp
+++ b/src/addinmanager.cpp
@@ -342,7 +342,10 @@ namespace gnote {
     for(AppAddinMap::const_iterator iter = m_app_addins.begin();
         iter != m_app_addins.end(); ++iter) {
       ApplicationAddin * addin = iter->second;
-      addin->initialize();
+      const sharp::DynamicModule * dmod
+        = m_module_manager.get_module(iter->first);
+      if (!dmod || dmod->enabled())
+        addin->initialize();
     }
   }
 
@@ -352,7 +355,10 @@ namespace gnote {
         iter != m_app_addins.end(); ++iter) {
       ApplicationAddin * addin = iter->second;
       try {
-        addin->shutdown();
+        const sharp::DynamicModule * dmod
+          = m_module_manager.get_module(iter->first);
+        if (!dmod || dmod->enabled())
+          addin->shutdown();
       }
       catch (const sharp::Exception & e) {
         DBG_OUT("Error calling %s.Shutdown (): %s",
diff --git a/src/sharp/modulemanager.cpp b/src/sharp/modulemanager.cpp
index 62a4b3c..299a545 100644
--- a/src/sharp/modulemanager.cpp
+++ b/src/sharp/modulemanager.cpp
@@ -95,4 +95,13 @@ namespace sharp {
     }
   }
 
+  const DynamicModule * ModuleManager::get_module(const std::string & id) const {
+    for(ModuleList::const_iterator iter = m_modules.begin();
+        iter != m_modules.end(); ++iter) {
+      if (id == (*iter)->id())
+        return *iter;
+    }
+    return 0;
+  }
+
 }
diff --git a/src/sharp/modulemanager.hpp b/src/sharp/modulemanager.hpp
index 9817037..30ce8d1 100644
--- a/src/sharp/modulemanager.hpp
+++ b/src/sharp/modulemanager.hpp
@@ -48,6 +48,7 @@ public:
   
   const ModuleList & get_modules() const
     { return m_modules; }
+  const DynamicModule * get_module(const std::string & id) const;
 private:
   std::set<std::string> m_dirs;
 
-- 
1.7.1



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