mirror of
https://github.com/subsurface/subsurface.git
synced 2025-02-19 22:16:15 +00:00
cleanup: don't allocate translators on heap
This is pointless bike-shedding: instead of allocating the QTranslators on the heap an assigning them to a variable at translation-unit scope, we can simply generate them as static objects. That makes 1) two fewer lines of code 2) the translator-resources are properly released when the application closes. Not that either of these points would make *any* difference. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
This commit is contained in:
parent
0f30ca9b33
commit
463bb25705
1 changed files with 8 additions and 10 deletions
|
@ -9,7 +9,7 @@
|
|||
#include "core/settings/qPref.h"
|
||||
|
||||
char *settings_suffix = NULL;
|
||||
static QTranslator *qtTranslator, *ssrfTranslator;
|
||||
static QTranslator qtTranslator, ssrfTranslator;
|
||||
|
||||
void init_qt_late()
|
||||
{
|
||||
|
@ -75,7 +75,6 @@ void init_qt_late()
|
|||
loc = getLocale();
|
||||
QLocale::setDefault(loc);
|
||||
|
||||
qtTranslator = new QTranslator;
|
||||
QString translationLocation;
|
||||
#if defined(Q_OS_ANDROID)
|
||||
translationLocation = QLatin1String("assets:/translations");
|
||||
|
@ -84,18 +83,17 @@ void init_qt_late()
|
|||
#else
|
||||
translationLocation = QLibraryInfo::location(QLibraryInfo::TranslationsPath);
|
||||
#endif
|
||||
if (qtTranslator->load(loc, "qt", "_", translationLocation)) {
|
||||
application->installTranslator(qtTranslator);
|
||||
if (qtTranslator.load(loc, "qt", "_", translationLocation)) {
|
||||
application->installTranslator(&qtTranslator);
|
||||
} else {
|
||||
if (verbose && uiLang != "en_US" && uiLang != "en-US")
|
||||
qDebug() << "can't find Qt localization for locale" << uiLang << "searching in" << translationLocation;
|
||||
}
|
||||
ssrfTranslator = new QTranslator;
|
||||
if (ssrfTranslator->load(loc, "subsurface", "_") ||
|
||||
ssrfTranslator->load(loc, "subsurface", "_", translationLocation) ||
|
||||
ssrfTranslator->load(loc, "subsurface", "_", getSubsurfaceDataPath("translations")) ||
|
||||
ssrfTranslator->load(loc, "subsurface", "_", getSubsurfaceDataPath("../translations"))) {
|
||||
application->installTranslator(ssrfTranslator);
|
||||
if (ssrfTranslator.load(loc, "subsurface", "_") ||
|
||||
ssrfTranslator.load(loc, "subsurface", "_", translationLocation) ||
|
||||
ssrfTranslator.load(loc, "subsurface", "_", getSubsurfaceDataPath("translations")) ||
|
||||
ssrfTranslator.load(loc, "subsurface", "_", getSubsurfaceDataPath("../translations"))) {
|
||||
application->installTranslator(&ssrfTranslator);
|
||||
} else {
|
||||
qDebug() << "can't find Subsurface localization for locale" << uiLang;
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue