Преглед изворни кода

limit past searches to 10 and 50 characters each

scott brogden пре 6 година
родитељ
комит
3794faf96b
2 измењених фајлова са 21 додато и 10 уклоњено
  1. 2 2
      Options.cpp
  2. 19 8
      SymbolEdit.cpp

+ 2 - 2
Options.cpp

@@ -2713,9 +2713,9 @@ void CGetSetOptions::SetToolTipTimeout(long val)
 
 CString CGetSetOptions::GetPastSearchXml()
 {
-	//max this out at 100000, this should be more than the allowed length in SymbolEdit.cpp
+	//max this out at 1000, this should be more than the allowed length in SymbolEdit.cpp
 	//had reports of this being really large and causing memory issues, this will prevent us from this
-	return GetProfileString("PastSearchXml", "", "", 100000);
+	return GetProfileString("PastSearchXml", "", "", 1000);
 }
 
 void CGetSetOptions::SetPastSearchXml(CString val)

+ 19 - 8
SymbolEdit.cpp

@@ -11,8 +11,8 @@
 
 #define RANGE_START 3000
 #define CLEAR_LIST 3050
-#define LIST_MAX_COUNT 50
-#define MAX_SAVED_SEARCH_LENGTH 1000
+#define LIST_MAX_COUNT 10
+#define MAX_SAVED_SEARCH_LENGTH 50
 
 IMPLEMENT_DYNAMIC(CSymbolEdit, CEdit)
 
@@ -229,17 +229,28 @@ void CSymbolEdit::LoadPastSearches(CString values)
 	{
 		TiXmlElement *ItemElement = ItemHeader->FirstChildElement();
 
+		int count = 0;
+
 		while (ItemElement)
 		{
-			CString item = ItemElement->Attribute("text");
+			if (count < LIST_MAX_COUNT)
+			{
+				CString item = ItemElement->Attribute("text");
 
-			CString toAdd = item.Left(MAX_SAVED_SEARCH_LENGTH);
-			if (toAdd != _T(""))
+				CString toAdd = item.Left(MAX_SAVED_SEARCH_LENGTH);
+				if (toAdd != _T(""))
+				{
+					m_searches.Add(toAdd);
+				}
+
+				ItemElement = ItemElement->NextSiblingElement();
+			}
+			else
 			{
-				m_searches.Add(toAdd);
+				break;
 			}
 
-			ItemElement = ItemElement->NextSiblingElement();
+			count++;
 		}
 	}
 }
@@ -250,7 +261,7 @@ void CSymbolEdit::AddToSearchHistory()
 	this->GetWindowText(cs);
 	if (cs != _T(""))
 	{
-		//only save up to 1000, had reports of somehow getting extremely large amounts of junk text
+		//only save up to 50, had reports of somehow getting extremely large amounts of junk text
 		//save and causing memory issues.
 		cs = cs.Left(MAX_SAVED_SEARCH_LENGTH);