mirror of
https://github.com/subsurface/subsurface.git
synced 2024-11-30 22:20:21 +00:00
130f109442
There was a curious pattern of singletons being implemented based on QScopedPointer<>s. This is an unnecessary level of indirection: The lifetime of the smart pointer is the same as that of the pointed-to object. Therefore, replace these pointers by the respective objects. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
28 lines
604 B
C++
28 lines
604 B
C++
// SPDX-License-Identifier: GPL-2.0
|
|
#include <QCoreApplication>
|
|
#include <QString>
|
|
#include "gettextfromc.h"
|
|
|
|
const char *gettextFromC::trGettext(const char *text)
|
|
{
|
|
QByteArray &result = translationCache[QByteArray(text)];
|
|
if (result.isEmpty())
|
|
result = translationCache[QByteArray(text)] = trUtf8(text).toUtf8();
|
|
return result.constData();
|
|
}
|
|
|
|
void gettextFromC::reset(void)
|
|
{
|
|
translationCache.clear();
|
|
}
|
|
|
|
gettextFromC *gettextFromC::instance()
|
|
{
|
|
static gettextFromC self;
|
|
return &self;
|
|
}
|
|
|
|
extern "C" const char *trGettext(const char *text)
|
|
{
|
|
return gettextFromC::instance()->trGettext(text);
|
|
}
|