summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--common/mainwnd.cpp27
1 files 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];