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:
authorCampbell Barton <campbell@blender.org>2022-09-14 07:06:39 +0300
committerCampbell Barton <campbell@blender.org>2022-09-14 07:06:39 +0300
commitf74fa63b5a5bd6d835abd51985430e0fa4e7fc2a (patch)
treee25e5f33908f57c78cdfcc825dce462b0a3504ea /source/creator
parente1a9c16176df30f0e3cdd89e113d6b8d41cd4647 (diff)
Cleanup: skip argument freeing when built as a Python module
Diffstat (limited to 'source/creator')
-rw-r--r--source/creator/creator.c42
1 files changed, 32 insertions, 10 deletions
diff --git a/source/creator/creator.c b/source/creator/creator.c
index 2d8b1e16098..2cd54deeab5 100644
--- a/source/creator/creator.c
+++ b/source/creator/creator.c
@@ -24,7 +24,6 @@
#include "DNA_genfile.h"
-#include "BLI_args.h"
#include "BLI_string.h"
#include "BLI_system.h"
#include "BLI_task.h"
@@ -51,6 +50,10 @@
#include "BKE_vfont.h"
#include "BKE_volume.h"
+#ifndef WITH_PYTHON_MODULE
+# include "BLI_args.h"
+#endif
+
#include "DEG_depsgraph.h"
#include "IMB_imbuf.h" /* For #IMB_init. */
@@ -94,6 +97,18 @@
#include "creator_intern.h" /* Own include. */
/* -------------------------------------------------------------------- */
+/** \name Local Defines
+ * \{ */
+
+/* When building as a Python module, don't use special argument handling
+ * so the module loading logic can control the `argv` & `argc`. */
+#if defined(WIN32) && !defined(WITH_PYTHON_MODULE)
+# define USE_WIN32_UNICODE_ARGS
+#endif
+
+/** \} */
+
+/* -------------------------------------------------------------------- */
/** \name Local Application State
* \{ */
@@ -132,23 +147,34 @@ static void main_callback_setup(void)
/* free data on early exit (if Python calls 'sys.exit()' while parsing args for eg). */
struct CreatorAtExitData {
+#ifndef WITH_PYTHON_MODULE
bArgs *ba;
-#ifdef WIN32
+#endif
+
+#ifdef USE_WIN32_UNICODE_ARGS
const char **argv;
int argv_num;
#endif
+
+#if defined(WITH_PYTHON_MODULE) && !defined(USE_WIN32_UNICODE_ARGS)
+ void *_empty; /* Prevent empty struct error with MSVC. */
+#endif
};
static void callback_main_atexit(void *user_data)
{
struct CreatorAtExitData *app_init_data = user_data;
+#ifndef WITH_PYTHON_MODULE
if (app_init_data->ba) {
BLI_args_destroy(app_init_data->ba);
app_init_data->ba = NULL;
}
+#else
+ UNUSED_VARS(app_init_data); /* May be unused. */
+#endif
-#ifdef WIN32
+#ifdef USE_WIN32_UNICODE_ARGS
if (app_init_data->argv) {
while (app_init_data->argv_num) {
free((void *)app_init_data->argv[--app_init_data->argv_num]);
@@ -156,6 +182,8 @@ static void callback_main_atexit(void *user_data)
free((void *)app_init_data->argv);
app_init_data->argv = NULL;
}
+#else
+ UNUSED_VARS(app_init_data); /* May be unused. */
#endif
}
@@ -233,12 +261,6 @@ void gmp_blender_init_allocator()
/** \name Main Function
* \{ */
-/* When building as a Python module, don't use special argument handling
- * so the module loading logic can control the `argv` & `argc`. */
-#if defined(WIN32) && !defined(WITH_PYTHON_MODULE)
-# define USE_WIN32_UNICODE_ARGS
-#endif
-
/**
* Blender's main function responsibilities are:
* - setup subsystems.
@@ -534,7 +556,7 @@ int main(int argc,
(void)ba;
#endif
-#ifdef WIN32
+#ifdef USE_WIN32_UNICODE_ARGS
argv = NULL;
(void)argv;
#endif