From 5d792b4cea12eaf00af8183d30eae2e8b976bbbc Mon Sep 17 00:00:00 2001 From: leo Date: Thu, 2 Jun 2005 21:14:41 +0000 Subject: Fixed a bug with the recent file list. git-svn-id: http://svn.leocad.org/trunk@397 c7d43263-9d01-0410-8a33-9dba5d9f93d6 --- common/mainwnd.cpp | 27 +++++++++++++++------------ 1 file changed, 15 insertions(+), 12 deletions(-) diff --git a/common/mainwnd.cpp b/common/mainwnd.cpp index 69e438c..6c644cd 100644 --- a/common/mainwnd.cpp +++ b/common/mainwnd.cpp @@ -71,24 +71,27 @@ void MainWnd::UpdateMRU () #endif } -void MainWnd::AddToMRU (const char *filename) +void MainWnd::AddToMRU(const char* Filename) { - // update the MRU list, if an existing MRU string matches file name - int i; + // Make a copy of the string in case we're loading a file from the MRU menu. + String str = Filename; + int i; - for (i = 0; i < (LC_MRU_MAX - 1); i++) - if (m_strMRU[i] == filename) - break; + // Search for Filename in the MRU list. + for (i = 0; i < (LC_MRU_MAX - 1); i++) + if (m_strMRU[i] == Filename) + break; - // move MRU strings before this one down - for (; i > 0; i--) - m_strMRU[i] = m_strMRU[i-1]; - m_strMRU[0] = filename; + // Move MRU strings before this one down. + for (; i > 0; i--) + m_strMRU[i] = m_strMRU[i-1]; - UpdateMRU (); + m_strMRU[0] = str; + + UpdateMRU(); } -void MainWnd::RemoveFromMRU (int index) +void MainWnd::RemoveFromMRU(int index) { for (int i = index; i < (LC_MRU_MAX - 1); i++) m_strMRU[i] = m_strMRU[i+1]; -- cgit v1.2.3