mirror of
https://github.com/subsurface/subsurface.git
synced 2024-12-01 06:30:26 +00:00
2ef80930ff
if trGettext() gets called with a *text that resides in the stack, the QHash will return incorrect values after the second call of trGettext() with that *text. Example (assuming nothing has been translated): void func(const char *text) { char *translated = trGettext(text); doSomethingWith(translated); } func("foo"); (1) func("bar"); (2) (1) *translated is "foo" (2) *translated should be "bar" but is "foo" because the key (const char*) points to the value "foo" which has been set in the previous call (1). Signed-off-by: Maximilian Güntner <maximilian.guentner@gmail.com>
18 lines
359 B
C++
18 lines
359 B
C++
#ifndef GETTEXTFROMC_H
|
|
#define GETTEXTFROMC_H
|
|
|
|
#include <QHash>
|
|
|
|
extern "C" const char *trGettext(const char *text);
|
|
|
|
class gettextFromC
|
|
{
|
|
Q_DECLARE_TR_FUNCTIONS(gettextFromC)
|
|
public:
|
|
static gettextFromC *instance();
|
|
const char *trGettext(const char *text);
|
|
void reset(void);
|
|
QHash <QByteArray , QByteArray> translationCache;
|
|
};
|
|
|
|
#endif // GETTEXTFROMC_H
|