From 756c40163d48aadc3e2d42de30cb3a693188556d Mon Sep 17 00:00:00 2001 From: Glenn Rice Date: Thu, 3 Mar 2011 22:47:48 +0000 Subject: 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 --- Source/Core/Common/Src/SysConf.cpp | 28 ++++++++++++++-------------- 1 file changed, 14 insertions(+), 14 deletions(-) (limited to 'Source/Core/Common/Src/SysConf.cpp') 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::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::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::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); -- cgit v1.2.3