summaryrefslogtreecommitdiffstats
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:28:04 +0900
commit8ca79ae1d02635a031a4fbc7a70658814a997ddd (patch)
treeec2ff273eef9eb6b2705f3816fe5fadd1e1c6e20
parentabd210d71bc55f8e39cf506f5b6326937d9dfc3d (diff)
downloadtdeedu-8ca79ae1d02635a031a4fbc7a70658814a997ddd.tar.gz
tdeedu-8ca79ae1d02635a031a4fbc7a70658814a997ddd.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> (cherry picked from commit aeb0ed94067ba967fc457533aec609152ac287ea)
-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>