[RAPPS] Make CConfigParser a temp object.

This commit is contained in:
Alexander Shaposhnikov 2017-10-22 00:52:49 +03:00
parent c9aa1915df
commit e554a359f3
No known key found for this signature in database
GPG key ID: 9EEC655FCB0EDE9F
2 changed files with 11 additions and 6 deletions

View file

@ -19,7 +19,7 @@
// CAvailableApplicationInfo // CAvailableApplicationInfo
CAvailableApplicationInfo::CAvailableApplicationInfo(const ATL::CStringW& sFileNameParam) CAvailableApplicationInfo::CAvailableApplicationInfo(const ATL::CStringW& sFileNameParam)
: m_IsInstalled(FALSE), m_HasLanguageInfo(FALSE), m_HasInstalledVersion(FALSE), m_Parser(sFileNameParam) : m_IsInstalled(FALSE), m_HasLanguageInfo(FALSE), m_HasInstalledVersion(FALSE)
{ {
m_LicenseType = LICENSE_NONE; m_LicenseType = LICENSE_NONE;
@ -39,11 +39,14 @@ VOID CAvailableApplicationInfo::RefreshAppInfo()
// Lazily load general info from the file // Lazily load general info from the file
VOID CAvailableApplicationInfo::RetrieveGeneralInfo() VOID CAvailableApplicationInfo::RetrieveGeneralInfo()
{ {
m_Category = m_Parser.GetInt(L"Category"); m_Parser = new CConfigParser(m_sFileName);
m_Category = m_Parser->GetInt(L"Category");
if (!GetString(L"Name", m_szName) if (!GetString(L"Name", m_szName)
|| !GetString(L"URLDownload", m_szUrlDownload)) || !GetString(L"URLDownload", m_szUrlDownload))
{ {
delete m_Parser;
return; return;
} }
@ -64,6 +67,8 @@ VOID CAvailableApplicationInfo::RetrieveGeneralInfo()
{ {
RetrieveInstalledVersion(); RetrieveInstalledVersion();
} }
delete m_Parser;
} }
VOID CAvailableApplicationInfo::RetrieveInstalledStatus() VOID CAvailableApplicationInfo::RetrieveInstalledStatus()
@ -87,7 +92,7 @@ VOID CAvailableApplicationInfo::RetrieveLanguages()
ATL::CStringW szBuffer; ATL::CStringW szBuffer;
// TODO: Get multiline parameter // TODO: Get multiline parameter
if (!m_Parser.GetString(L"Languages", szBuffer)) if (!m_Parser->GetString(L"Languages", szBuffer))
{ {
m_HasLanguageInfo = FALSE; m_HasLanguageInfo = FALSE;
return; return;
@ -126,7 +131,7 @@ VOID CAvailableApplicationInfo::RetrieveLanguages()
VOID CAvailableApplicationInfo::RetrieveLicenseType() VOID CAvailableApplicationInfo::RetrieveLicenseType()
{ {
INT IntBuffer = m_Parser.GetInt(L"LicenseType"); INT IntBuffer = m_Parser->GetInt(L"LicenseType");
if (IsLicenseType(IntBuffer)) if (IsLicenseType(IntBuffer))
{ {
@ -195,7 +200,7 @@ VOID CAvailableApplicationInfo::SetLastWriteTime(FILETIME* ftTime)
inline BOOL CAvailableApplicationInfo::GetString(LPCWSTR lpKeyName, ATL::CStringW& ReturnedString) inline BOOL CAvailableApplicationInfo::GetString(LPCWSTR lpKeyName, ATL::CStringW& ReturnedString)
{ {
if (!m_Parser.GetString(lpKeyName, ReturnedString)) if (!m_Parser->GetString(lpKeyName, ReturnedString))
{ {
ReturnedString.Empty(); ReturnedString.Empty();
return FALSE; return FALSE;

View file

@ -64,7 +64,7 @@ private:
BOOL m_IsInstalled; BOOL m_IsInstalled;
BOOL m_HasLanguageInfo; BOOL m_HasLanguageInfo;
BOOL m_HasInstalledVersion; BOOL m_HasInstalledVersion;
CConfigParser m_Parser; CConfigParser* m_Parser;
inline BOOL GetString(LPCWSTR lpKeyName, ATL::CStringW& ReturnedString); inline BOOL GetString(LPCWSTR lpKeyName, ATL::CStringW& ReturnedString);