From 9a18d7308a8116d2affbb37fecc8212fce9ef481 Mon Sep 17 00:00:00 2001 From: "fix94.1" Date: Fri, 9 Aug 2013 17:14:31 +0000 Subject: [PATCH] -fixed overwriting the existing language properly -added some debug prints into the language downloader --- source/config/config.cpp | 2 ++ source/menu/menu_language.cpp | 6 ++++++ 2 files changed, 8 insertions(+) diff --git a/source/config/config.cpp b/source/config/config.cpp index 37d40245..93cb7ad1 100644 --- a/source/config/config.cpp +++ b/source/config/config.cpp @@ -185,6 +185,7 @@ bool Config::load(const char *filename) } } } + file.close(); /* not sure if needed */ m_loaded = true; return m_loaded; } @@ -209,6 +210,7 @@ void Config::save(bool unload) for (Config::KeyMap::iterator l = m->begin(); l != m->end(); ++l) file << l->first << '=' << escNewlines(l->second) << '\n'; } + file.close(); /* not sure if needed */ m_changed = false; } if(unload) this->unload(); diff --git a/source/menu/menu_language.cpp b/source/menu/menu_language.cpp index f78a18b1..a1379295 100644 --- a/source/menu/menu_language.cpp +++ b/source/menu/menu_language.cpp @@ -120,6 +120,7 @@ void CMenu::_showLangSettings(void) m_btnMgr.show(m_LangSettingsLblDownload); 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); m_btnMgr.setText(m_LangSettingsLblCurDLLang, dl_lang_ex); } @@ -205,6 +206,7 @@ bool CMenu::_LangSettings(void) language_cnt++; tmp = strstr(tmp, "\n") + 1; /* next line */ } + gprintf("Found %u languages\n", language_cnt); /* creating list */ tmp = start; 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); 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))); + //gprintf("%s added\n", lang_list_mem[i].lang); tmp = strstr(tmp, "\n") + 1; /* next line */ } + //gprintf("Finished creating the list\n"); free(m_buffer); m_buffer = NULL; } @@ -235,11 +239,13 @@ bool CMenu::_LangSettings(void) const char *language_sel = lang_list_mem[mem_pos].lang; const char *language_url_sel = fmt("%s%s.ini", LANGUAGE_URL, language_sel); _downloadUrl(language_url_sel, &file, &filesize); + m_loc.unload(); if(m_buffer != NULL) { const char *language_ini = fmt("%s/%s.ini", m_languagesDir.c_str(), language_sel); fsop_deleteFile(language_ini); fsop_WriteFile(language_ini, file, filesize); + gprintf("Wrote %s with the size %u\n", language_ini, filesize); free(m_buffer); m_buffer = NULL; }