summaryrefslogtreecommitdiffstats
path: root/khangman
diff options
context:
space:
mode:
authorMichele Calgaro <michele.calgaro@yahoo.it>2020-11-29 16:24:18 +0900
committerMichele Calgaro <michele.calgaro@yahoo.it>2020-11-29 16:24:18 +0900
commitaeb0ed94067ba967fc457533aec609152ac287ea (patch)
tree47fb143778e5d362c191827805fe8609c52e0aee /khangman
parent5e2daefa0208fb8041d2c878a0cb4d7e6661d337 (diff)
downloadtdeedu-aeb0ed94067ba967fc457533aec609152ac287ea.tar.gz
tdeedu-aeb0ed94067ba967fc457533aec609152ac287ea.zip
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>
Diffstat (limited to 'khangman')
-rw-r--r--khangman/khangman/khangman.cpp12
-rw-r--r--khangman/khangman/khangman.kcfg12
2 files changed, 15 insertions, 9 deletions
diff --git a/khangman/khangman/khangman.cpp b/khangman/khangman/khangman.cpp
index 6b54405b..99459074 100644
--- a/khangman/khangman/khangman.cpp
+++ b/khangman/khangman/khangman.cpp
@@ -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();
diff --git a/khangman/khangman/khangman.kcfg b/khangman/khangman/khangman.kcfg
index 9916b5ed..6d792bf8 100644
--- a/khangman/khangman/khangman.kcfg
+++ b/khangman/khangman/khangman.kcfg
@@ -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>