Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'source/blender/python/intern/bpy_app_translations.c')
-rw-r--r--source/blender/python/intern/bpy_app_translations.c44
1 files changed, 24 insertions, 20 deletions
diff --git a/source/blender/python/intern/bpy_app_translations.c b/source/blender/python/intern/bpy_app_translations.c
index 0114e8e65e4..123b111f3cb 100644
--- a/source/blender/python/intern/bpy_app_translations.c
+++ b/source/blender/python/intern/bpy_app_translations.c
@@ -44,8 +44,8 @@
#include "BLF_translation.h"
#include "RNA_types.h"
-#include "RNA_access.h"
+#include "../generic/python_utildefines.h"
typedef struct
{
@@ -242,12 +242,9 @@ static void _build_translations_cache(PyObject *py_messages, const char *locale)
}
/* Clean up! */
- if (language)
- MEM_freeN(language);
- if (language_country)
- MEM_freeN(language_country);
- if (language_variant)
- MEM_freeN(language_variant);
+ MEM_SAFE_FREE(language);
+ MEM_SAFE_FREE(language_country);
+ MEM_SAFE_FREE(language_variant);
}
const char *BPY_app_translations_py_pgettext(const char *msgctxt, const char *msgid)
@@ -263,7 +260,7 @@ const char *BPY_app_translations_py_pgettext(const char *msgctxt, const char *ms
return msgid;
tmp = BLF_lang_get();
- if (strcmp(tmp, locale) || !_translations_cache) {
+ if (!STREQ(tmp, locale) || !_translations_cache) {
PyGILState_STATE _py_state;
BLI_strncpy(locale, tmp, STATIC_LOCALE_SIZE);
@@ -410,7 +407,7 @@ static PyObject *app_translations_contexts_make(void)
}
#define SetObjString(item) PyStructSequence_SET_ITEM(translations_contexts, pos++, PyUnicode_FromString((item)))
-#define SetObjNone() Py_INCREF(Py_None); PyStructSequence_SET_ITEM(translations_contexts, pos++, Py_None)
+#define SetObjNone() PyStructSequence_SET_ITEM(translations_contexts, pos++, Py_INCREF_RET(Py_None))
for (ctxt = _contexts; ctxt->c_id; ctxt++) {
if (ctxt->value) {
@@ -430,11 +427,11 @@ static PyObject *app_translations_contexts_make(void)
/***** Main BlenderAppTranslations Py object definition *****/
PyDoc_STRVAR(app_translations_contexts_doc,
- "A named tuple containing all pre-defined translation contexts.\n"
- "\n"
- ".. warning::\n"
- " Never use a (new) context starting with \"" BLF_I18NCONTEXT_DEFAULT_BPYRNA "\", it would be internally \n"
- " assimilated as the default one!\n"
+"A named tuple containing all pre-defined translation contexts.\n"
+"\n"
+".. warning::\n"
+" Never use a (new) context starting with \"" BLF_I18NCONTEXT_DEFAULT_BPYRNA "\", it would be internally \n"
+" assimilated as the default one!\n"
);
PyDoc_STRVAR(app_translations_contexts_C_to_py_doc,
@@ -450,8 +447,8 @@ static PyMemberDef app_translations_members[] = {
};
PyDoc_STRVAR(app_translations_locale_doc,
- "The actual locale currently in use (will always return a void string when Blender is built without "
- "internationalization support)."
+"The actual locale currently in use (will always return a void string when Blender is built without "
+"internationalization support)."
);
static PyObject *app_translations_locale_get(PyObject *UNUSED(self), void *UNUSED(userdata))
{
@@ -520,9 +517,7 @@ static PyObject *_py_pgettext(PyObject *args, PyObject *kw, const char *(*_pgett
return NULL;
}
- Py_INCREF(msgid);
-
- return msgid;
+ return Py_INCREF_RET(msgid);
#endif
}
@@ -632,6 +627,7 @@ PyDoc_STRVAR(app_translations_locale_explode_doc,
);
static PyObject *app_translations_locale_explode(BlenderAppTranslations *UNUSED(self), PyObject *args, PyObject *kw)
{
+ PyObject *ret_tuple;
static const char *kwlist[] = {"locale", NULL};
const char *locale;
char *language, *country, *variant, *language_country, *language_variant;
@@ -642,7 +638,15 @@ static PyObject *app_translations_locale_explode(BlenderAppTranslations *UNUSED(
BLF_locale_explode(locale, &language, &country, &variant, &language_country, &language_variant);
- return Py_BuildValue("sssss", language, country, variant, language_country, language_variant);
+ ret_tuple = Py_BuildValue("sssss", language, country, variant, language_country, language_variant);
+
+ MEM_SAFE_FREE(language);
+ MEM_SAFE_FREE(country);
+ MEM_SAFE_FREE(variant);
+ MEM_SAFE_FREE(language_country);
+ MEM_SAFE_FREE(language_variant);
+
+ return ret_tuple;
}
static PyMethodDef app_translations_methods[] = {