Fix double delete issue 62/63762/4
authorLi Zhang <li2012.zhang@samsung.com>
Fri, 25 Mar 2016 14:20:37 +0000 (22:20 +0800)
committerLi Zhang <li2012.zhang@samsung.com>
Fri, 25 Mar 2016 14:57:31 +0000 (22:57 +0800)
Change-Id: I43fc5dbffee316053fa57cdfdf48434c7b2fc077

ism/extras/efl_panel/isf_panel_efl.cpp
ism/modules/panelagent/ecoresocket/ecore_socket_panel_agent_module.cpp
ism/modules/panelagent/wayland/wayland_panel_agent_module.cpp
ism/src/isf_info_manager.cpp
ism/src/isf_panel_agent_manager.cpp
ism/src/isf_panel_agent_module.cpp
ism/src/isf_panel_agent_module.h

index 5adf018..8bb6f44 100644 (file)
@@ -129,7 +129,7 @@ using namespace scim;
 extern MapStringVectorSizeT         _groups;
 extern std::vector<ImeInfoDB>       _ime_info;
 
-extern EXAPI CommonLookupTable       g_isf_candidate_table;
+CommonLookupTable       g_isf_candidate_table;
 
 
 /////////////////////////////////////////////////////////////////////////////
index 0565bb2..e80cbf7 100644 (file)
@@ -52,9 +52,6 @@
 
 #define IMEMANAGER_PRIVILEGE "http://tizen.org/privilege/imemanager"
 
-EXAPI scim::CommonLookupTable g_isf_candidate_table;
-
-
 namespace scim
 {
 
@@ -2877,7 +2874,7 @@ private:
 /***************************************************/
 /*** Beginning of panel agent interface for ISF ***/
 /***************************************************/
-static scim::PanelAgentBase* instance = NULL;
+static scim::PanelAgentPointer instance;
 
 extern "C" {
 
@@ -2887,10 +2884,7 @@ extern "C" {
 
     EXAPI void scim_module_exit(void)
     {
-        if (instance) {
-            delete instance;
-            instance = NULL;
-        }
+        instance.reset();
     }
 
     EXAPI void scim_panel_agent_module_init(const scim::ConfigPointer& config)
@@ -2899,17 +2893,18 @@ extern "C" {
 
     EXAPI scim::PanelAgentPointer scim_panel_agent_module_get_instance()
     {
-
-        if (!instance) {
+        scim::PanelAgentBase* _instance = NULL;
+        if (instance.null()) {
             try {
-                instance = new scim::EcoreSocketPanelAgent();
+                _instance = new scim::EcoreSocketPanelAgent();
             } catch (...) {
-                delete instance;
-                instance = NULL;
+                delete _instance;
+                _instance = NULL;
             }
+            if(_instance)
+                instance = _instance;
         }
-
-        return scim::PanelAgentPointer(instance);
+        return instance;
     }
 }
 
index 7fdc43f..11821cf 100644 (file)
@@ -4378,7 +4378,7 @@ public:
 
 };
 
-static scim::PanelAgentBase* instance = NULL;
+static scim::PanelAgentPointer instance;
 extern "C" {
 
     EXAPI void scim_module_init (void)
@@ -4389,10 +4389,7 @@ extern "C" {
     EXAPI void scim_module_exit (void)
     {
         LOGD ("");
-        if (instance) {
-            delete instance;
-            instance = NULL;
-        }
+        instance.reset();
     }
 
     EXAPI void scim_panel_agent_module_init (const scim::ConfigPointer& config)
@@ -4403,17 +4400,19 @@ extern "C" {
 
     EXAPI scim::PanelAgentPointer scim_panel_agent_module_get_instance ()
     {
-        if (!instance) {
+        scim::PanelAgentBase* _instance = NULL;
+        if (instance.null()) {
             try {
-                LOGD ("");
-                instance = new WaylandPanelAgent ();
+                _instance = new WaylandPanelAgent();
             } catch (...) {
-                delete instance;
-                instance = NULL;
+                delete _instance;
+                _instance = NULL;
             }
+            if(_instance)
+                instance = _instance;
         }
+        return instance;
 
-        return scim::PanelAgentPointer (instance);
     }
 }
 
index 9c8b277..7d11e5b 100644 (file)
@@ -75,9 +75,6 @@
 #define MIN_REPEAT_TIME     2.0
 
 
-EXAPI scim::CommonLookupTable g_isf_candidate_table;
-
-
 namespace scim
 {
 
index bdfe6d9..6aba004 100644 (file)
@@ -77,9 +77,12 @@ public:
     }
 
     ~PanelAgentManagerImpl () {
+        m_socket.reset(0);
+        m_wayland.reset(0);
         std::vector<PanelAgentModule*>::iterator iter = m_panel_agent_modules.begin ();
 
         for (; iter != m_panel_agent_modules.end (); iter++) {
+            (*iter)->unload();
             delete *iter;
         }
 
index 72214ff..2787150 100644 (file)
@@ -88,6 +88,12 @@ PanelAgentModule::load (const String& name, const ConfigPointer& config)
 }
 
 bool
+PanelAgentModule::unload ()
+{
+    return m_module.unload ();
+}
+
+bool
 PanelAgentModule::valid () const
 {
     return (m_module.valid () && m_panel_agent_init && m_panel_agent_get_instance);
index 41efe55..0b90852 100644 (file)
@@ -115,6 +115,12 @@ public:
     bool load (const String& name, const ConfigPointer& config);
 
     /**
+     * @brief Unload the PanelAgent Module.
+     * @return true if sucessfully unloaded.
+     */
+    bool unload ();
+
+    /**
      * @brief Check if a module is loaded and initialized successfully.
      *
      * @return true if a module is already loaded and initialized successfully.