From 2e43769108d4023c215451fa8116abdc991e0f19 Mon Sep 17 00:00:00 2001 From: Dirk Hohndel Date: Tue, 8 Oct 2013 22:44:38 -0700 Subject: Avoid the memory leaks from translations Instead use a hash to cache the translations (and allow for the ability to clear the hash so we can even switch translations at runtime...). Now Qt will keep track of the memory and release it for us when we are done with it. This avoids the memory leak introduced in commit 4ecb35bf5ff2 ("Make a copy of the translated text"). Signed-off-by: Dirk Hohndel --- gettextfromc.h | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) (limited to 'gettextfromc.h') diff --git a/gettextfromc.h b/gettextfromc.h index 3852709c9..7d7bca142 100644 --- a/gettextfromc.h +++ b/gettextfromc.h @@ -1,6 +1,7 @@ -#ifndef GETTEXT_H -#define GETTEXT_H +#ifndef GETTEXTFROMC_H +#define GETTEXTFROMC_H +#include extern "C" const char *gettext(const char *text); @@ -9,7 +10,9 @@ class gettextFromC Q_DECLARE_TR_FUNCTIONS(gettextFromC) public: static gettextFromC *instance(); - char *gettext(const char *text); + const char *gettext(const char *text); + void reset(void); + QHash translationCache; }; -#endif // GETTEXT_H +#endif // GETTEXTFROMC_H -- cgit v1.2.3-70-g09d2