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
This commit is contained in:
Glenn Rice
2011-03-03 22:47:48 +00:00
parent 05719ac81a
commit 756c40163d
4 changed files with 105 additions and 123 deletions

View File

@ -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);