From 92df44c844b176ea58d89c8c7ca8ece3957ec263 Mon Sep 17 00:00:00 2001
From: Alexandre Savard <alexandresavard@alexandresavard-desktop.(none)>
Date: Fri, 2 Apr 2010 12:21:43 -0400
Subject: [PATCH] [#3116] Delete history items

---
 .../src/history/historymanager.cpp            | 10 ++++++
 sflphone-common/src/managerimpl.cpp           | 33 ++++++++++---------
 2 files changed, 28 insertions(+), 15 deletions(-)

diff --git a/sflphone-common/src/history/historymanager.cpp b/sflphone-common/src/history/historymanager.cpp
index 1fb5b99154..e28ffff1a5 100644
--- a/sflphone-common/src/history/historymanager.cpp
+++ b/sflphone-common/src/history/historymanager.cpp
@@ -32,9 +32,19 @@ HistoryManager::HistoryManager ()
 
 HistoryManager::~HistoryManager ()
 {
+	 HistoryItemMap::iterator iter = _history_items.begin();
+
+	 HistoryItem * item;
+	 while(iter != _history_items.end()){
+		 item = iter->second;
+		 delete item;
+		 iter++;
+	 }
+
 
     // Clear the history map
     _history_items.clear ();
+
 }
 
 int HistoryManager::load_history (int limit, std::string path)
diff --git a/sflphone-common/src/managerimpl.cpp b/sflphone-common/src/managerimpl.cpp
index f7196d2f14..b994f4b02f 100644
--- a/sflphone-common/src/managerimpl.cpp
+++ b/sflphone-common/src/managerimpl.cpp
@@ -91,9 +91,10 @@ ManagerImpl::ManagerImpl (void) :
 // never call if we use only the singleton...
 ManagerImpl::~ManagerImpl (void) {
 	// terminate();
-	delete _cleaner;
-	_cleaner = 0;
-	_debug ("%s stop correctly.", PROGNAME);
+	delete _cleaner; _cleaner = NULL;
+	delete _history; _history = NULL;
+
+	_debug ("Manager: %s stop correctly.", PROGNAME);
 }
 
 void ManagerImpl::init () {
@@ -104,7 +105,7 @@ void ManagerImpl::init () {
 	initVolume();
 
 	if (_exist == 0) {
-		_debug ("Cannot create config file in your home directory");
+		_warn ("Manager: Cannot create config file in your home directory");
 	}
 
 	initAudioDriver();
@@ -119,11 +120,11 @@ void ManagerImpl::init () {
 	if (audiolayer != 0) {
 		unsigned int sampleRate = audiolayer->getSampleRate();
 
-		_debugInit ("Load Telephone Tone");
+		_debugInit ("Manager: Load telephone tone");
 		std::string country = getConfigString(PREFERENCES, ZONE_TONE);
 		_telephoneTone = new TelephoneTone(country, sampleRate);
 
-		_debugInit ("Loading DTMF key");
+		_debugInit ("Manager: Loading DTMF key");
 		_dtmfKey = new DTMF(sampleRate);
 	}
 
@@ -135,23 +136,25 @@ void ManagerImpl::init () {
 }
 
 void ManagerImpl::terminate () {
-	_debug ("ManagerImpl::terminate ");
+
+	_debug ("Manager: Terminate ");
 	saveConfig();
 
 	unloadAccountMap();
 
-	_debug ("Unload DTMF Key ");
+	_debug ("Manager: Unload DTMF key");
 	delete _dtmfKey;
 
-	_debug ("Unload Audio Driver ");
-	delete _audiodriver;
-	_audiodriver = NULL;
+	_debug("Manager: Unload telephone tone");
+	delete _telephoneTone; _telephoneTone = NULL;
+
+	_debug ("Manager: Unload audio driver");
+	delete _audiodriver; _audiodriver = NULL;
 
-	_debug ("Unload Telephone Tone ");
-	delete _telephoneTone;
-	_telephoneTone = NULL;
+	_debug ("Manager: Unload telephone tone");
+	delete _telephoneTone; _telephoneTone = NULL;
 
-	_debug ("Unload Audio Codecs ");
+	_debug ("Manager: Unload audio codecs ");
 	_codecDescriptorMap.deleteHandlePointer();
 
 }
-- 
GitLab