kdecore: return the value of KGlobal::hasLocale() from KDETranslator::isEmpty() and check it from KDETranslator::translate()

fixes possible crash due to accessing the private KLocale data after
destruction

Signed-off-by: Ivailo Monev <xakepa10@gmail.com>
This commit is contained in:
Ivailo Monev 2022-11-06 10:07:51 +02:00
parent 7baf0c9d61
commit e07fc01227

View file

@ -41,12 +41,15 @@ class KDETranslator : public QTranslator
public:
QString translate(const char *context, const char *sourceText) const final
{
if (isEmpty()) {
return QString();
}
return KGlobal::locale()->translateQt(context, sourceText);
}
bool isEmpty() const final
{
return false;
return !KGlobal::hasLocale();
}
};
#endif // QT_NO_TRANSLATION