summaryrefslogtreecommitdiff
path: root/Source/Core/Common
diff options
context:
space:
mode:
authorGlenn Rice <glennricster@gmail.com>2011-03-03 22:47:48 +0000
committerGlenn Rice <glennricster@gmail.com>2011-03-03 22:47:48 +0000
commit756c40163d48aadc3e2d42de30cb3a693188556d (patch)
treec32eb762459962607984d9b4e1ba94a970028699 /Source/Core/Common
parent05719ac81ab1e784c7aeb85af1e9b227b9cdbe83 (diff)
Merge the log window CreateGUIControls and LoadSettings methods. This allows the settings from the ini file to be applied when the controls are created rather than setting a default, and then changing the settings later. In particular word wrap is applied when the text control is created. This works around the crash at application start that users are reporting in issue 4196.
Also change the for loops in SysConf to use iterators to placate godisgovernment and billiard. :P git-svn-id: https://dolphin-emu.googlecode.com/svn/trunk@7283 8ced0084-cf51-0410-be5f-012b33b47a6e
Diffstat (limited to 'Source/Core/Common')
-rw-r--r--Source/Core/Common/Src/SysConf.cpp28
-rw-r--r--Source/Core/Common/Src/SysConf.h40
2 files changed, 34 insertions, 34 deletions
diff --git a/Source/Core/Common/Src/SysConf.cpp b/Source/Core/Common/Src/SysConf.cpp
index f98ef21e41..af45ca525d 100644
--- a/Source/Core/Common/Src/SysConf.cpp
+++ b/Source/Core/Common/Src/SysConf.cpp
@@ -36,11 +36,9 @@ SysConf::~SysConf()
void SysConf::Clear()
{
- for (size_t i = 0; i < m_Entries.size() - 1; i++)
- {
- delete [] m_Entries[i].data;
- m_Entries[i].data = NULL;
- }
+ for (std::vector<SSysConfEntry>::const_iterator i = m_Entries.begin();
+ i < m_Entries.end() - 1; i++)
+ delete [] i->data;
m_Entries.clear();
}
@@ -86,9 +84,10 @@ bool SysConf::LoadFromFileInternal(FILE *f)
}
// Last offset is an invalid entry. We ignore it throughout this class
- for (size_t i = 0; i < m_Entries.size() - 1; i++)
+ for (std::vector<SSysConfEntry>::iterator i = m_Entries.begin();
+ i < m_Entries.end() - 1; i++)
{
- SSysConfEntry& curEntry = m_Entries[i];
+ SSysConfEntry& curEntry = *i;
if (fseeko(f, curEntry.offset, SEEK_SET) != 0) return false;
u8 description = 0;
@@ -144,22 +143,23 @@ bool SysConf::SaveToFile(const char *filename)
if (f == NULL)
return false;
- for (size_t i = 0; i < m_Entries.size() - 1; i++)
+ for (std::vector<SSysConfEntry>::iterator i = m_Entries.begin();
+ i < m_Entries.end() - 1; i++)
{
// Seek to after the name of this entry
- if (fseeko(f, m_Entries[i].offset + m_Entries[i].nameLength + 1, SEEK_SET) != 0) return false;
+ if (fseeko(f, i->offset + i->nameLength + 1, SEEK_SET) != 0) return false;
// We may have to write array length value...
- if (m_Entries[i].type == Type_BigArray)
+ if (i->type == Type_BigArray)
{
- u16 tmpDataLength = Common::swap16(m_Entries[i].dataLength);
+ u16 tmpDataLength = Common::swap16(i->dataLength);
if (fwrite(&tmpDataLength, 2, 1, f) != 1) return false;
}
- else if (m_Entries[i].type == Type_SmallArray)
+ else if (i->type == Type_SmallArray)
{
- if (fwrite(&m_Entries[i].dataLength, 1, 1, f) != 1) return false;
+ if (fwrite(&i->dataLength, 1, 1, f) != 1) return false;
}
// Now write the actual data
- if (fwrite(m_Entries[i].data, m_Entries[i].dataLength, 1, f) != 1) return false;
+ if (fwrite(i->data, i->dataLength, 1, f) != 1) return false;
}
fclose(f);
diff --git a/Source/Core/Common/Src/SysConf.h b/Source/Core/Common/Src/SysConf.h
index bb15722af6..6041e70ee8 100644
--- a/Source/Core/Common/Src/SysConf.h
+++ b/Source/Core/Common/Src/SysConf.h
@@ -93,19 +93,19 @@ public:
return 0;
}
- size_t index = 0;
- for (; index < m_Entries.size() - 1; index++)
+ std::vector<SSysConfEntry>::iterator index = m_Entries.begin();
+ for (; index < m_Entries.end() - 1; index++)
{
- if (strcmp(m_Entries[index].name, sectionName) == 0)
+ if (strcmp(index->name, sectionName) == 0)
break;
}
- if (index == m_Entries.size() - 1)
+ if (index == m_Entries.end() - 1)
{
PanicAlertT("Section %s not found in SYSCONF", sectionName);
return 0;
}
- return m_Entries[index].GetData<T>();
+ return index->GetData<T>();
}
bool GetArrayData(const char* sectionName, u8* dest, u16 destSize)
@@ -116,19 +116,19 @@ public:
return 0;
}
- size_t index = 0;
- for (; index < m_Entries.size() - 1; index++)
+ std::vector<SSysConfEntry>::iterator index = m_Entries.begin();
+ for (; index < m_Entries.end() - 1; index++)
{
- if (strcmp(m_Entries[index].name, sectionName) == 0)
+ if (strcmp(index->name, sectionName) == 0)
break;
}
- if (index == m_Entries.size() - 1)
+ if (index == m_Entries.end() - 1)
{
PanicAlertT("Section %s not found in SYSCONF", sectionName);
return 0;
}
- return m_Entries[index].GetArrayData(dest, destSize);
+ return index->GetArrayData(dest, destSize);
}
bool SetArrayData(const char* sectionName, u8* buffer, u16 bufferSize)
@@ -136,19 +136,19 @@ public:
if (!m_IsValid)
return false;
- size_t index = 0;
- for (; index < m_Entries.size() - 1; index++)
+ std::vector<SSysConfEntry>::iterator index = m_Entries.begin();
+ for (; index < m_Entries.end() - 1; index++)
{
- if (strcmp(m_Entries[index].name, sectionName) == 0)
+ if (strcmp(index->name, sectionName) == 0)
break;
}
- if (index == m_Entries.size() - 1)
+ if (index == m_Entries.end() - 1)
{
PanicAlertT("Section %s not found in SYSCONF", sectionName);
return false;
}
- return m_Entries[index].SetArrayData(buffer, bufferSize);
+ return index->SetArrayData(buffer, bufferSize);
}
template<class T>
@@ -157,19 +157,19 @@ public:
if (!m_IsValid)
return false;
- size_t index = 0;
- for (; index < m_Entries.size() - 1; index++)
+ std::vector<SSysConfEntry>::iterator index = m_Entries.begin();
+ for (; index < m_Entries.end() - 1; index++)
{
- if (strcmp(m_Entries[index].name, sectionName) == 0)
+ if (strcmp(index->name, sectionName) == 0)
break;
}
- if (index == m_Entries.size() - 1)
+ if (index == m_Entries.end() - 1)
{
PanicAlertT("Section %s not found in SYSCONF", sectionName);
return false;
}
- *(T*)m_Entries[index].data = newValue;
+ *(T*)index->data = newValue;
return true;
}