khangman: fixed invalid assert and infinite loop triggered when the

selected language at startup is no longer available. This resolves bug 3171.

Signed-off-by: Michele Calgaro <michele.calgaro@yahoo.it>
pull/14/head
Michele Calgaro 4 years ago
parent 5e2daefa02
commit aeb0ed9406
Signed by: MicheleC
GPG Key ID: 2A75B7CA8ADED5CF

@ -235,7 +235,6 @@ void KHangMan::setLanguages()
// tdelibs/tdecore/all_languages to find the name of the country
// corresponding to the code and the language the user set.
TDEConfig entry(locate("locale", "all_languages"));
const TQStringList::ConstIterator itEnd = m_languages.end();
for (TQStringList::Iterator it = m_languages.begin();
it != m_languages.end(); ++it) {
entry.setGroup(*it);
@ -257,11 +256,14 @@ void KHangMan::setLanguages()
void KHangMan::loadSettings()
{
// Language //TODO is selectedLanguage necessary??? only used here
selectedLanguage = Prefs::selectedLanguage();
if (m_languages.grep(selectedLanguage).isEmpty())
selectedLanguage = "en";
changeStatusbar(m_languageNames[m_languages.findIndex(Prefs::selectedLanguage())], IDS_LANG);
if (m_languages.contains(selectedLanguage) == 0)
{
selectedLanguage = "en";
m_view->khangman->slotChangeLanguage(m_view->khangman->m_languages.findIndex(selectedLanguage));
m_languageAction->setCurrentItem(m_languages.findIndex(selectedLanguage));
}
changeStatusbar(m_languageNames[m_languages.findIndex(selectedLanguage)], IDS_LANG);
// Show/hide characters toolbar
if (Prefs::showCharToolbar())
secondToolbar->show();

@ -22,12 +22,16 @@
<code>
TDEConfigBase *globalConf = TDEGlobal::config();
globalConf->setGroup("Locale");
QString userLanguage = globalConf->readEntry("Language", "en");
TQString userLanguage = globalConf->readEntry("Language", "en");
if (userLanguage.isEmpty())
userLanguage = "en";
{
userLanguage = "en";
}
else
//keep only the first 2 characters
userLanguage = userLanguage.left(2);
{
//keep only the first 2 characters
userLanguage = userLanguage.left(2);
}
</code>
<default code="true">userLanguage</default>
</entry>

Loading…
Cancel
Save