From 86330091629199f15fba4f1de0ca698c112300e0 Mon Sep 17 00:00:00 2001 From: vng Date: Thu, 19 Jul 2012 22:09:15 -0700 Subject: [PATCH] Fix issue when mwm file is an invalid map (file is broken), we should delete it by request too. --- indexer/mwm_set.cpp | 11 +++++++++-- indexer/mwm_set.hpp | 3 +++ 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/indexer/mwm_set.cpp b/indexer/mwm_set.cpp index 32dc71e1d8..12d34e5dc5 100644 --- a/indexer/mwm_set.cpp +++ b/indexer/mwm_set.cpp @@ -90,12 +90,19 @@ MwmSet::MwmId MwmSet::GetFreeId() MwmSet::MwmId MwmSet::GetIdByName(string const & name) { + ASSERT ( !name.empty(), () ); + for (MwmId i = 0; i < m_info.size(); ++i) { UpdateMwmInfo(i); + if (m_name[i] == name) + { + ASSERT_NOT_EQUAL ( m_info[i].m_status, MwmInfo::STATUS_REMOVED, () ); return i; + } } + return INVALID_MWM_ID; } @@ -167,10 +174,10 @@ void MwmSet::Remove(string const & fileName) bool MwmSet::RemoveImpl(string const & fileName) { - bool ret = false; + bool ret = true; MwmId const id = GetIdByName(fileName); - if (id != INVALID_MWM_ID && m_info[id].IsExist()) + if (id != INVALID_MWM_ID) { ret = RemoveImpl(id); diff --git a/indexer/mwm_set.hpp b/indexer/mwm_set.hpp index 0a362d7ab0..8e7124fd2b 100644 --- a/indexer/mwm_set.hpp +++ b/indexer/mwm_set.hpp @@ -91,8 +91,11 @@ public: /// @name Remove mwm. //@{ protected: + /// @return true - map is free; false - map is busy + //@{ bool RemoveImpl(MwmId id); bool RemoveImpl(string const & fileName); + //@} public: void Remove(string const & fileName);