-fixed overwriting the existing language properly

-added some debug prints into the language downloader
This commit is contained in:
fix94.1 2013-08-09 17:14:31 +00:00
parent 675f81f5e4
commit 9a18d7308a
2 changed files with 8 additions and 0 deletions

View File

@ -185,6 +185,7 @@ bool Config::load(const char *filename)
} }
} }
} }
file.close(); /* not sure if needed */
m_loaded = true; m_loaded = true;
return m_loaded; return m_loaded;
} }
@ -209,6 +210,7 @@ void Config::save(bool unload)
for (Config::KeyMap::iterator l = m->begin(); l != m->end(); ++l) for (Config::KeyMap::iterator l = m->begin(); l != m->end(); ++l)
file << l->first << '=' << escNewlines(l->second) << '\n'; file << l->first << '=' << escNewlines(l->second) << '\n';
} }
file.close(); /* not sure if needed */
m_changed = false; m_changed = false;
} }
if(unload) this->unload(); if(unload) this->unload();

View File

@ -120,6 +120,7 @@ void CMenu::_showLangSettings(void)
m_btnMgr.show(m_LangSettingsLblDownload); m_btnMgr.show(m_LangSettingsLblDownload);
m_btnMgr.show(m_LangSettingsBtnDownload); m_btnMgr.show(m_LangSettingsBtnDownload);
//gprintf("Currently %s selected (pos %u)\n", lang_list_mem[mem_pos].lang, mem_pos);
dl_lang_ex.fromUTF8(lang_list_mem[mem_pos].lang); dl_lang_ex.fromUTF8(lang_list_mem[mem_pos].lang);
m_btnMgr.setText(m_LangSettingsLblCurDLLang, dl_lang_ex); m_btnMgr.setText(m_LangSettingsLblCurDLLang, dl_lang_ex);
} }
@ -205,6 +206,7 @@ bool CMenu::_LangSettings(void)
language_cnt++; language_cnt++;
tmp = strstr(tmp, "\n") + 1; /* next line */ tmp = strstr(tmp, "\n") + 1; /* next line */
} }
gprintf("Found %u languages\n", language_cnt);
/* creating list */ /* creating list */
tmp = start; tmp = start;
lang_list_mem = (language_list*)MEM2_alloc(language_cnt*sizeof(language_list)); lang_list_mem = (language_list*)MEM2_alloc(language_cnt*sizeof(language_list));
@ -214,8 +216,10 @@ bool CMenu::_LangSettings(void)
tmp = strstr(tmp, search_char); tmp = strstr(tmp, search_char);
char *lang_chr = strchr(tmp, 0x22) + 1; /* the " is the beginning for the name */ char *lang_chr = strchr(tmp, 0x22) + 1; /* the " is the beginning for the name */
memcpy(lang_list_mem[i].lang, lang_chr, std::min(31u, (u32)(strchr(lang_chr, '.') - lang_chr))); memcpy(lang_list_mem[i].lang, lang_chr, std::min(31u, (u32)(strchr(lang_chr, '.') - lang_chr)));
//gprintf("%s added\n", lang_list_mem[i].lang);
tmp = strstr(tmp, "\n") + 1; /* next line */ tmp = strstr(tmp, "\n") + 1; /* next line */
} }
//gprintf("Finished creating the list\n");
free(m_buffer); free(m_buffer);
m_buffer = NULL; m_buffer = NULL;
} }
@ -235,11 +239,13 @@ bool CMenu::_LangSettings(void)
const char *language_sel = lang_list_mem[mem_pos].lang; const char *language_sel = lang_list_mem[mem_pos].lang;
const char *language_url_sel = fmt("%s%s.ini", LANGUAGE_URL, language_sel); const char *language_url_sel = fmt("%s%s.ini", LANGUAGE_URL, language_sel);
_downloadUrl(language_url_sel, &file, &filesize); _downloadUrl(language_url_sel, &file, &filesize);
m_loc.unload();
if(m_buffer != NULL) if(m_buffer != NULL)
{ {
const char *language_ini = fmt("%s/%s.ini", m_languagesDir.c_str(), language_sel); const char *language_ini = fmt("%s/%s.ini", m_languagesDir.c_str(), language_sel);
fsop_deleteFile(language_ini); fsop_deleteFile(language_ini);
fsop_WriteFile(language_ini, file, filesize); fsop_WriteFile(language_ini, file, filesize);
gprintf("Wrote %s with the size %u\n", language_ini, filesize);
free(m_buffer); free(m_buffer);
m_buffer = NULL; m_buffer = NULL;
} }