summaryrefslogtreecommitdiffstats
path: root/gettextfromc.cpp
AgeCommit message (Collapse)Author
2014-02-27Massive automated whitespace cleanupGravatar Dirk Hohndel
I know everyone will hate it. Go ahead. Complain. Call me names. At least now things are consistent and reproducible. If you want changes, have your complaint come with a patch to scripts/whitespace.pl so that we can automate it. Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2013-11-30Fix all leak-at-exit from singletons in SubsurfaceGravatar Thiago Macieira
Subsurface creates a lot of singleton instances on demand, but nothing ever deleted them. Since they are singletons, these memory allocations are technically not leaks. However, they clutter the output in valgrind and other memory analysers, hiding the real issues. The solution is to delete these items at exit. For the models and for gettextFromC, the solution is to use a QScopedPointer, which will delete its payload when it gets destroyed. For the dialogs and other widgets, we can't do that: they need to be deleted before QApplication exits, so we just set the parent in all of them to the main window. Signed-off-by: Thiago Macieira <thiago@macieira.org> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2013-11-15Support translating UTF8 stringsGravatar Maximilian Güntner
Interpreting UTF8 encoded strings using tr() instead of trUtf8() and encoding the string back to utf8 again leads to serious encoding errors. Fixes #230 Signed-off-by: Maximilian Güntner <maximilian.guentner@gmail.com> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2013-11-02change the key from const char * to QByteArrayGravatar Maximilian Güntner
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>
2013-10-10Dismbiguate gettextGravatar Dirk Hohndel
Just to make sure there's no confusion - we are NOT calling gettext. We are calling tr from a gettext like interface. Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2013-10-08Avoid the memory leaks from translationsGravatar Dirk Hohndel
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 <dirk@hohndel.org>
2013-10-08Make a copy of the translated textGravatar Dirk Hohndel
Otherwise the translation will get freed (and often reused) before it makes it to the screen. The problem with this is that it leaks memory for every translation. Reported-by: Robert C. Helling <helling@atdotde.de> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2013-10-06Trying to switch to Qt translationGravatar Dirk Hohndel
This compiles and looks about right, but it doesn't appear to work, yet. Signed-off-by: Dirk Hohndel <dirk@hohndel.org>