2023-05-31 16:19:06 +02:00
|
|
|
/* SPDX-FileCopyrightText: 2001-2002 NaN Holding BV. All rights reserved.
|
|
|
|
|
*
|
|
|
|
|
* SPDX-License-Identifier: GPL-2.0-or-later */
|
2002-10-12 11:37:38 +00:00
|
|
|
|
2019-02-18 08:08:12 +11:00
|
|
|
/** \file
|
|
|
|
|
* \ingroup bke
|
2016-04-24 22:42:41 +10:00
|
|
|
*
|
|
|
|
|
* Application level startup/shutdown functionality.
|
2011-02-27 20:40:57 +00:00
|
|
|
*/
|
|
|
|
|
|
2023-07-22 11:27:25 +10:00
|
|
|
#include <cstdio>
|
|
|
|
|
#include <cstdlib>
|
|
|
|
|
#include <cstring>
|
2002-10-12 11:37:38 +00:00
|
|
|
|
2025-01-28 15:27:34 +01:00
|
|
|
#include "DNA_windowmanager_types.h"
|
|
|
|
|
|
2002-10-12 11:37:38 +00:00
|
|
|
#include "MEM_guardedalloc.h"
|
Giant commit!
A full detailed description of this will be done later... is several days
of work. Here's a summary:
Render:
- Full cleanup of render code, removing *all* globals and bad level calls
all over blender. Render module is now not called abusive anymore
- API-fied calls to rendering
- Full recode of internal render pipeline. Is now rendering tiles by
default, prepared for much smarter 'bucket' render later.
- Each thread now can render a full part
- Renders were tested with 4 threads, goes fine, apart from some lookup
tables in softshadow and AO still
- Rendering is prepared to do multiple layers and passes
- No single 32 bits trick in render code anymore, all 100% floats now.
Writing images/movies
- moved writing images to blender kernel (bye bye 'schrijfplaatje'!)
- made a new Movie handle system, also in kernel. This will enable much
easier use of movies in Blender
PreviewRender:
- Using new render API, previewrender (in buttons) now uses regular render
code to generate images.
- new datafile 'preview.blend.c' has the preview scenes in it
- previews get rendered in exact displayed size (1 pixel = 1 pixel)
3D Preview render
- new; press Pkey in 3d window, for a panel that continuously renders
(pkey is for games, i know... but we dont do that in orange now!)
- this render works nearly identical to buttons-preview render, so it stops
rendering on any event (mouse, keyboard, etc)
- on moving/scaling the panel, the render code doesn't recreate all geometry
- same for shifting/panning view
- all other operations (now) regenerate the full render database still.
- this is WIP... but big fun, especially for simple scenes!
Compositor
- Using same node system as now in use for shaders, you can composit images
- works pretty straightforward... needs much more options/tools and integration
with rendering still
- is not threaded yet, nor is so smart to only recalculate changes... will be
done soon!
- the "Render Result" node will get all layers/passes as output sockets
- The "Output" node renders to a builtin image, which you can view in the Image
window. (yes, output nodes to render-result, and to files, is on the list!)
The Bad News
- "Unified Render" is removed. It might come back in some stage, but this
system should be built from scratch. I can't really understand this code...
I expect it is not much needed, especially with advanced layer/passes
control
- Panorama render, Field render, Motion blur, is not coded yet... (I had to
recode every single feature in render, so...!)
- Lens Flare is also not back... needs total revision, might become composit
effect though (using zbuffer for visibility)
- Part render is gone! (well, thats obvious, its default now).
- The render window is only restored with limited functionality... I am going
to check first the option to render to a Image window, so Blender can become
a true single-window application. :)
For example, the 'Spare render buffer' (jkey) doesnt work.
- Render with border, now default creates a smaller image
- No zbuffers are written yet... on the todo!
- Scons files and MSVC will need work to get compiling again
OK... thats what I can quickly recall. Now go compiling!
2006-01-23 22:05:47 +00:00
|
|
|
|
2025-01-26 20:07:57 +01:00
|
|
|
#include "DNA_windowmanager_types.h"
|
|
|
|
|
|
2016-04-24 22:42:41 +10:00
|
|
|
#include "BLI_listbase.h"
|
2020-03-19 09:33:03 +01:00
|
|
|
#include "BLI_string.h"
|
2011-01-07 18:36:47 +00:00
|
|
|
#include "BLI_utildefines.h"
|
2004-11-07 16:49:46 +00:00
|
|
|
|
2024-01-18 22:50:23 +02:00
|
|
|
#include "IMB_imbuf.hh"
|
|
|
|
|
#include "IMB_moviecache.hh"
|
2002-10-12 11:37:38 +00:00
|
|
|
|
2024-12-20 13:23:08 +01:00
|
|
|
#include "MOV_util.hh"
|
|
|
|
|
|
2018-02-12 17:24:18 +11:00
|
|
|
#include "BKE_addon.h"
|
2025-04-04 18:38:53 +02:00
|
|
|
#include "BKE_appdir.hh"
|
2024-05-03 10:20:01 -04:00
|
|
|
#include "BKE_asset.hh"
|
2024-02-09 19:52:55 +01:00
|
|
|
#include "BKE_blender.hh" /* own include */
|
2024-01-21 19:34:20 +01:00
|
|
|
#include "BKE_blender_user_menu.hh" /* own include */
|
|
|
|
|
#include "BKE_blender_version.h" /* own include */
|
2023-08-02 22:14:18 +02:00
|
|
|
#include "BKE_brush.hh"
|
2024-02-09 19:29:34 +01:00
|
|
|
#include "BKE_callbacks.hh"
|
2024-02-10 18:25:14 +01:00
|
|
|
#include "BKE_global.hh"
|
2024-03-26 12:57:30 -04:00
|
|
|
#include "BKE_idprop.hh"
|
2023-12-01 19:43:16 +01:00
|
|
|
#include "BKE_main.hh"
|
2024-02-19 15:26:10 +01:00
|
|
|
#include "BKE_node.hh"
|
2023-09-25 17:48:21 -04:00
|
|
|
#include "BKE_screen.hh"
|
2018-06-20 09:29:40 +02:00
|
|
|
#include "BKE_studiolight.h"
|
Holiday coding log :)
Nice formatted version (pictures soon):
http://wiki.blender.org/index.php/Dev:Ref/Release_Notes/2.66/Usability
Short list of main changes:
- Transparent region option (over main region), added code to blend in/out such panels.
- Min size window now 640 x 480
- Fixed DPI for ui - lots of cleanup and changes everywhere. Icon image need correct size still, layer-in-use icon needs remake.
- Macbook retina support, use command line --no-native-pixels to disable it
- Timeline Marker label was drawing wrong
- Trackpad and magic mouse: supports zoom (hold ctrl)
- Fix for splash position: removed ghost function and made window size update after creation immediate
- Fast undo buffer save now adds UI as well. Could be checked for regular file save even...
Quit.blend and temp file saving use this now.
- Dixed filename in window on reading quit.blend or temp saves, and they now add a warning in window title: "(Recovered)"
- New Userpref option "Keep Session" - this always saves quit.blend, and loads on start.
This allows keeping UI and data without actual saves, until you actually save.
When you load startup.blend and quit, it recognises the quit.blend as a startup (no file name in header)
- Added 3D view copy/paste buffers (selected objects). Shortcuts ctrl-c, ctrl-v (OSX, cmd-c, cmd-v).
Coded partial file saving for it. Could be used for other purposes. Todo: use OS clipboards.
- User preferences (themes, keymaps, user settings) now can be saved as a separate file.
Old option is called "Save Startup File" the new one "Save User Settings".
To visualise this difference, the 'save startup file' button has been removed from user preferences window. That option is available as CTRL+U and in File menu still.
- OSX: fixed bug that stopped giving mouse events outside window.
This also fixes "Continuous Grab" for OSX. (error since 2009)
2012-12-12 18:58:11 +00:00
|
|
|
|
2023-09-22 03:18:17 +02:00
|
|
|
#include "DEG_depsgraph.hh"
|
2017-04-06 16:11:50 +02:00
|
|
|
|
2020-11-09 15:42:38 +01:00
|
|
|
#include "RE_texture.h"
|
2002-10-12 11:37:38 +00:00
|
|
|
|
2024-01-31 14:04:56 -05:00
|
|
|
#include "BLF_api.hh"
|
Holiday coding log :)
Nice formatted version (pictures soon):
http://wiki.blender.org/index.php/Dev:Ref/Release_Notes/2.66/Usability
Short list of main changes:
- Transparent region option (over main region), added code to blend in/out such panels.
- Min size window now 640 x 480
- Fixed DPI for ui - lots of cleanup and changes everywhere. Icon image need correct size still, layer-in-use icon needs remake.
- Macbook retina support, use command line --no-native-pixels to disable it
- Timeline Marker label was drawing wrong
- Trackpad and magic mouse: supports zoom (hold ctrl)
- Fix for splash position: removed ghost function and made window size update after creation immediate
- Fast undo buffer save now adds UI as well. Could be checked for regular file save even...
Quit.blend and temp file saving use this now.
- Dixed filename in window on reading quit.blend or temp saves, and they now add a warning in window title: "(Recovered)"
- New Userpref option "Keep Session" - this always saves quit.blend, and loads on start.
This allows keeping UI and data without actual saves, until you actually save.
When you load startup.blend and quit, it recognises the quit.blend as a startup (no file name in header)
- Added 3D view copy/paste buffers (selected objects). Shortcuts ctrl-c, ctrl-v (OSX, cmd-c, cmd-v).
Coded partial file saving for it. Could be used for other purposes. Todo: use OS clipboards.
- User preferences (themes, keymaps, user settings) now can be saved as a separate file.
Old option is called "Save Startup File" the new one "Save User Settings".
To visualise this difference, the 'save startup file' button has been removed from user preferences window. That option is available as CTRL+U and in File menu still.
- OSX: fixed bug that stopped giving mouse events outside window.
This also fixes "Continuous Grab" for OSX. (error since 2009)
2012-12-12 18:58:11 +00:00
|
|
|
|
Fix #130463, #114592: VSE prefetching uses wrong font for text strips
Prefetching happens on a background thread by design, and so it was not loading
any fonts and using the default monospace font.
Address this by making all font usage within VSE use "unique" BLF font objects,
and protecting concurrent access to them or their state within VSE itself:
- SeqFontMap structure to hold a mutex, file path -> font ID map (for file
based fonts), name -> font ID map (for datablock fonts).
- seq_load_font_file, seq_load_font_mem, seq_unload_font that use the above
instead of calling into BLF directly.
- Text effect rendering part guards with a mutex, so that font render state and
glyph cache does not get trashed.
- SeqFontMap is global instead of some Scene-specific runtime data (e.g.
scene->ed), because right now there's a hard max limit of total number of
fonts (64), and if each copy of the VSE data would start to load their own
unique fonts, that limit could get easily reached.
- BLF font loading/unloading code is now thread safe. The rest of BLF drawing
is still not!
If at some point in the future BLF font usage becomes thread safe, and font
drawing becomes "stateless", this whole machinery can be removed.
Pull Request: https://projects.blender.org/blender/blender/pulls/130542
2024-11-25 12:15:22 +01:00
|
|
|
#include "SEQ_utils.hh"
|
|
|
|
|
|
2002-10-12 11:37:38 +00:00
|
|
|
Global G;
|
|
|
|
|
UserDef U;
|
|
|
|
|
|
2020-09-17 15:34:10 +10:00
|
|
|
/* -------------------------------------------------------------------- */
|
|
|
|
|
/** \name Blender Free on Exit
|
|
|
|
|
* \{ */
|
2002-10-12 11:37:38 +00:00
|
|
|
|
2023-07-18 14:18:07 +10:00
|
|
|
void BKE_blender_free()
|
2002-10-12 11:37:38 +00:00
|
|
|
{
|
2023-07-17 10:46:26 +02:00
|
|
|
/* samples are in a global list..., also sets G_MAIN->sound->sample nullptr */
|
2018-06-20 09:29:40 +02:00
|
|
|
|
2022-11-02 10:14:37 +11:00
|
|
|
/* Needs to run before main free as window-manager is still referenced for icons preview jobs. */
|
2019-04-27 12:07:07 +10:00
|
|
|
BKE_studiolight_free();
|
|
|
|
|
|
2022-10-05 12:55:32 +02:00
|
|
|
BKE_blender_globals_clear();
|
2002-10-12 11:37:38 +00:00
|
|
|
|
2023-07-17 10:46:26 +02:00
|
|
|
if (G.log.file != nullptr) {
|
|
|
|
|
fclose(static_cast<FILE *>(G.log.file));
|
2018-03-29 20:38:32 +02:00
|
|
|
}
|
|
|
|
|
|
2012-05-06 17:22:54 +00:00
|
|
|
BKE_spacetypes_free(); /* after free main, it uses space callbacks */
|
2018-06-17 17:05:51 +02:00
|
|
|
|
Merge image related changes from the render branch. This includes the image
tile cache code in imbuf, but it is not hooked up to the render engine.
Imbuf module: some small refactoring and removing a lot of unused or old code
(about 6.5k lines).
* Added a ImFileType struct with callbacks to make adding an file format type,
or making changes to the API easier.
* Move imbuf init/exit code into IMB_init()/IMB_exit() functions.
* Increased mipmap levels from 10 to 20, you run into this limit already with
a 2k image.
* Removed hamx, amiga, anim5 format support.
* Removed colormap saving, only simple colormap code now for reading tga.
* Removed gen_dynlibtiff.py, editing this is almost as much work as just
editing the code directly.
* Functions removed that were only used for sequencer plugin API:
IMB_anim_nextpic, IMB_clever_double, IMB_antialias, IMB_gamwarp,
IMB_scalefieldImBuf, IMB_scalefastfieldImBuf, IMB_onethird, IMB_halflace,
IMB_dit0, IMB_dit2, IMB_cspace
* Write metadata info into OpenEXR images. Can be viewed with the command
line utility 'exrheader'
For the image tile cache code, see this page:
http://wiki.blender.org/index.php/Dev:2.5/Source/Imaging/ImageTileCache
2010-05-07 15:18:04 +00:00
|
|
|
IMB_exit();
|
2017-04-06 16:11:50 +02:00
|
|
|
DEG_free_node_types();
|
2013-03-19 14:25:12 +00:00
|
|
|
|
|
|
|
|
BKE_brush_system_exit();
|
2018-06-17 17:05:51 +02:00
|
|
|
RE_texture_rng_exit();
|
2011-06-24 16:54:30 +00:00
|
|
|
|
2019-09-05 15:52:38 +02:00
|
|
|
BKE_callback_global_finalize();
|
2011-06-24 16:54:30 +00:00
|
|
|
|
2011-10-23 17:52:20 +00:00
|
|
|
IMB_moviecache_destruct();
|
2025-03-06 13:04:39 +01:00
|
|
|
blender::seq::fontmap_clear();
|
2024-12-20 13:23:08 +01:00
|
|
|
MOV_exit();
|
2017-05-03 11:38:17 +02:00
|
|
|
|
2024-08-19 20:27:37 +02:00
|
|
|
blender::bke::node_system_exit();
|
2002-10-12 11:37:38 +00:00
|
|
|
}
|
|
|
|
|
|
2020-09-17 15:34:10 +10:00
|
|
|
/** \} */
|
|
|
|
|
|
|
|
|
|
/* -------------------------------------------------------------------- */
|
|
|
|
|
/** \name Blender Version Access
|
|
|
|
|
* \{ */
|
|
|
|
|
|
|
|
|
|
static char blender_version_string[48] = "";
|
|
|
|
|
|
2023-09-16 02:37:06 +02:00
|
|
|
/* Only includes patch if non-zero. */
|
|
|
|
|
static char blender_version_string_compact[48] = "";
|
|
|
|
|
|
2023-07-18 14:18:07 +10:00
|
|
|
static void blender_version_init()
|
2017-03-15 14:10:20 +01:00
|
|
|
{
|
Blender: change bugfix release versioning from a/b/c to .1/.2/.3
The file subversion is no longer used in the Python API or user interface,
and is now internal to Blender.
User interface, Python API and file I/O metadata now use more consistent
formatting for version numbers. Official releases use "2.83.0", "2.83.1",
and releases under development use "2.90.0 Alpha", "2.90.0 Beta".
Some Python add-ons may need to lower the Blender version in bl_info to
(2, 83, 0) or (2, 90, 0) if they used a subversion number higher than 0.
https://wiki.blender.org/wiki/Reference/Release_Notes/2.83/Python_API#Compatibility
This change is in preparation of LTS releases, and also brings us more
in line with semantic versioning.
Fixes T76058.
Differential Revision: https://developer.blender.org/D7748
2020-05-25 10:49:04 +02:00
|
|
|
const char *version_cycle = "";
|
2024-08-01 00:06:18 +02:00
|
|
|
const char *version_cycle_compact = "";
|
Blender: change bugfix release versioning from a/b/c to .1/.2/.3
The file subversion is no longer used in the Python API or user interface,
and is now internal to Blender.
User interface, Python API and file I/O metadata now use more consistent
formatting for version numbers. Official releases use "2.83.0", "2.83.1",
and releases under development use "2.90.0 Alpha", "2.90.0 Beta".
Some Python add-ons may need to lower the Blender version in bl_info to
(2, 83, 0) or (2, 90, 0) if they used a subversion number higher than 0.
https://wiki.blender.org/wiki/Reference/Release_Notes/2.83/Python_API#Compatibility
This change is in preparation of LTS releases, and also brings us more
in line with semantic versioning.
Fixes T76058.
Differential Revision: https://developer.blender.org/D7748
2020-05-25 10:49:04 +02:00
|
|
|
if (STREQ(STRINGIFY(BLENDER_VERSION_CYCLE), "alpha")) {
|
|
|
|
|
version_cycle = " Alpha";
|
2024-08-01 00:06:18 +02:00
|
|
|
version_cycle_compact = " a";
|
Blender: change bugfix release versioning from a/b/c to .1/.2/.3
The file subversion is no longer used in the Python API or user interface,
and is now internal to Blender.
User interface, Python API and file I/O metadata now use more consistent
formatting for version numbers. Official releases use "2.83.0", "2.83.1",
and releases under development use "2.90.0 Alpha", "2.90.0 Beta".
Some Python add-ons may need to lower the Blender version in bl_info to
(2, 83, 0) or (2, 90, 0) if they used a subversion number higher than 0.
https://wiki.blender.org/wiki/Reference/Release_Notes/2.83/Python_API#Compatibility
This change is in preparation of LTS releases, and also brings us more
in line with semantic versioning.
Fixes T76058.
Differential Revision: https://developer.blender.org/D7748
2020-05-25 10:49:04 +02:00
|
|
|
}
|
|
|
|
|
else if (STREQ(STRINGIFY(BLENDER_VERSION_CYCLE), "beta")) {
|
|
|
|
|
version_cycle = " Beta";
|
2024-08-01 00:06:18 +02:00
|
|
|
version_cycle_compact = " b";
|
Blender: change bugfix release versioning from a/b/c to .1/.2/.3
The file subversion is no longer used in the Python API or user interface,
and is now internal to Blender.
User interface, Python API and file I/O metadata now use more consistent
formatting for version numbers. Official releases use "2.83.0", "2.83.1",
and releases under development use "2.90.0 Alpha", "2.90.0 Beta".
Some Python add-ons may need to lower the Blender version in bl_info to
(2, 83, 0) or (2, 90, 0) if they used a subversion number higher than 0.
https://wiki.blender.org/wiki/Reference/Release_Notes/2.83/Python_API#Compatibility
This change is in preparation of LTS releases, and also brings us more
in line with semantic versioning.
Fixes T76058.
Differential Revision: https://developer.blender.org/D7748
2020-05-25 10:49:04 +02:00
|
|
|
}
|
|
|
|
|
else if (STREQ(STRINGIFY(BLENDER_VERSION_CYCLE), "rc")) {
|
|
|
|
|
version_cycle = " Release Candidate";
|
2024-08-01 00:06:18 +02:00
|
|
|
version_cycle_compact = " RC";
|
Blender: change bugfix release versioning from a/b/c to .1/.2/.3
The file subversion is no longer used in the Python API or user interface,
and is now internal to Blender.
User interface, Python API and file I/O metadata now use more consistent
formatting for version numbers. Official releases use "2.83.0", "2.83.1",
and releases under development use "2.90.0 Alpha", "2.90.0 Beta".
Some Python add-ons may need to lower the Blender version in bl_info to
(2, 83, 0) or (2, 90, 0) if they used a subversion number higher than 0.
https://wiki.blender.org/wiki/Reference/Release_Notes/2.83/Python_API#Compatibility
This change is in preparation of LTS releases, and also brings us more
in line with semantic versioning.
Fixes T76058.
Differential Revision: https://developer.blender.org/D7748
2020-05-25 10:49:04 +02:00
|
|
|
}
|
|
|
|
|
else if (STREQ(STRINGIFY(BLENDER_VERSION_CYCLE), "release")) {
|
|
|
|
|
version_cycle = "";
|
2024-08-01 00:06:18 +02:00
|
|
|
version_cycle_compact = "";
|
2017-03-15 14:10:20 +01:00
|
|
|
}
|
|
|
|
|
else {
|
2021-07-15 18:23:28 +10:00
|
|
|
BLI_assert_msg(0, "Invalid Blender version cycle");
|
2017-03-15 14:10:20 +01:00
|
|
|
}
|
Blender: change bugfix release versioning from a/b/c to .1/.2/.3
The file subversion is no longer used in the Python API or user interface,
and is now internal to Blender.
User interface, Python API and file I/O metadata now use more consistent
formatting for version numbers. Official releases use "2.83.0", "2.83.1",
and releases under development use "2.90.0 Alpha", "2.90.0 Beta".
Some Python add-ons may need to lower the Blender version in bl_info to
(2, 83, 0) or (2, 90, 0) if they used a subversion number higher than 0.
https://wiki.blender.org/wiki/Reference/Release_Notes/2.83/Python_API#Compatibility
This change is in preparation of LTS releases, and also brings us more
in line with semantic versioning.
Fixes T76058.
Differential Revision: https://developer.blender.org/D7748
2020-05-25 10:49:04 +02:00
|
|
|
|
2024-08-01 00:06:18 +02:00
|
|
|
const char *version_suffix = BKE_blender_version_is_lts() ? " LTS" : "";
|
|
|
|
|
|
2023-05-09 12:50:37 +10:00
|
|
|
SNPRINTF(blender_version_string,
|
2024-08-01 21:57:31 +02:00
|
|
|
"%d.%01d.%d%s%s",
|
2023-05-09 12:50:37 +10:00
|
|
|
BLENDER_VERSION / 100,
|
|
|
|
|
BLENDER_VERSION % 100,
|
2024-08-01 21:57:31 +02:00
|
|
|
BLENDER_VERSION_PATCH,
|
2024-08-01 00:06:18 +02:00
|
|
|
version_suffix,
|
2023-05-09 12:50:37 +10:00
|
|
|
version_cycle);
|
2023-09-16 02:37:06 +02:00
|
|
|
|
|
|
|
|
SNPRINTF(blender_version_string_compact,
|
2024-08-01 21:57:31 +02:00
|
|
|
"%d.%01d.%d%s",
|
2023-09-16 02:37:06 +02:00
|
|
|
BLENDER_VERSION / 100,
|
|
|
|
|
BLENDER_VERSION % 100,
|
2024-08-01 21:57:31 +02:00
|
|
|
BLENDER_VERSION_PATCH,
|
2024-08-01 00:06:18 +02:00
|
|
|
version_cycle_compact);
|
Blender: change bugfix release versioning from a/b/c to .1/.2/.3
The file subversion is no longer used in the Python API or user interface,
and is now internal to Blender.
User interface, Python API and file I/O metadata now use more consistent
formatting for version numbers. Official releases use "2.83.0", "2.83.1",
and releases under development use "2.90.0 Alpha", "2.90.0 Beta".
Some Python add-ons may need to lower the Blender version in bl_info to
(2, 83, 0) or (2, 90, 0) if they used a subversion number higher than 0.
https://wiki.blender.org/wiki/Reference/Release_Notes/2.83/Python_API#Compatibility
This change is in preparation of LTS releases, and also brings us more
in line with semantic versioning.
Fixes T76058.
Differential Revision: https://developer.blender.org/D7748
2020-05-25 10:49:04 +02:00
|
|
|
}
|
|
|
|
|
|
2023-07-18 14:18:07 +10:00
|
|
|
const char *BKE_blender_version_string()
|
Blender: change bugfix release versioning from a/b/c to .1/.2/.3
The file subversion is no longer used in the Python API or user interface,
and is now internal to Blender.
User interface, Python API and file I/O metadata now use more consistent
formatting for version numbers. Official releases use "2.83.0", "2.83.1",
and releases under development use "2.90.0 Alpha", "2.90.0 Beta".
Some Python add-ons may need to lower the Blender version in bl_info to
(2, 83, 0) or (2, 90, 0) if they used a subversion number higher than 0.
https://wiki.blender.org/wiki/Reference/Release_Notes/2.83/Python_API#Compatibility
This change is in preparation of LTS releases, and also brings us more
in line with semantic versioning.
Fixes T76058.
Differential Revision: https://developer.blender.org/D7748
2020-05-25 10:49:04 +02:00
|
|
|
{
|
|
|
|
|
return blender_version_string;
|
2017-03-15 14:10:20 +01:00
|
|
|
}
|
|
|
|
|
|
2023-09-16 02:37:06 +02:00
|
|
|
const char *BKE_blender_version_string_compact()
|
|
|
|
|
{
|
|
|
|
|
return blender_version_string_compact;
|
|
|
|
|
}
|
|
|
|
|
|
2023-07-23 20:29:29 +02:00
|
|
|
void BKE_blender_version_blendfile_string_from_values(char *str_buff,
|
2023-08-06 16:03:10 +10:00
|
|
|
const size_t str_buff_maxncpy,
|
2023-07-23 20:29:29 +02:00
|
|
|
const short file_version,
|
|
|
|
|
const short file_subversion)
|
|
|
|
|
{
|
|
|
|
|
const short file_version_major = file_version / 100;
|
|
|
|
|
const short file_version_minor = file_version % 100;
|
|
|
|
|
if (file_subversion >= 0) {
|
|
|
|
|
BLI_snprintf(str_buff,
|
2023-08-06 16:03:10 +10:00
|
|
|
str_buff_maxncpy,
|
2023-07-23 20:29:29 +02:00
|
|
|
"%d.%d (sub %d)",
|
|
|
|
|
file_version_major,
|
|
|
|
|
file_version_minor,
|
|
|
|
|
file_subversion);
|
|
|
|
|
}
|
|
|
|
|
else {
|
2023-08-06 16:03:10 +10:00
|
|
|
BLI_snprintf(str_buff, str_buff_maxncpy, "%d.%d", file_version_major, file_version_minor);
|
2023-07-23 20:29:29 +02:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2023-07-18 14:18:07 +10:00
|
|
|
bool BKE_blender_version_is_alpha()
|
2020-08-17 19:50:35 +02:00
|
|
|
{
|
2020-08-18 15:58:53 +02:00
|
|
|
bool is_alpha = STREQ(STRINGIFY(BLENDER_VERSION_CYCLE), "alpha");
|
2020-08-17 19:50:35 +02:00
|
|
|
return is_alpha;
|
|
|
|
|
}
|
|
|
|
|
|
2024-08-01 00:06:18 +02:00
|
|
|
bool BKE_blender_version_is_lts()
|
|
|
|
|
{
|
|
|
|
|
return STREQ(STRINGIFY(BLENDER_VERSION_SUFFIX), "LTS");
|
|
|
|
|
}
|
|
|
|
|
|
2020-09-17 15:34:10 +10:00
|
|
|
/** \} */
|
|
|
|
|
|
|
|
|
|
/* -------------------------------------------------------------------- */
|
|
|
|
|
/** \name Blender #Global Initialize/Clear
|
|
|
|
|
* \{ */
|
|
|
|
|
|
2023-07-18 14:18:07 +10:00
|
|
|
void BKE_blender_globals_init()
|
2002-10-12 11:37:38 +00:00
|
|
|
{
|
Blender: change bugfix release versioning from a/b/c to .1/.2/.3
The file subversion is no longer used in the Python API or user interface,
and is now internal to Blender.
User interface, Python API and file I/O metadata now use more consistent
formatting for version numbers. Official releases use "2.83.0", "2.83.1",
and releases under development use "2.90.0 Alpha", "2.90.0 Beta".
Some Python add-ons may need to lower the Blender version in bl_info to
(2, 83, 0) or (2, 90, 0) if they used a subversion number higher than 0.
https://wiki.blender.org/wiki/Reference/Release_Notes/2.83/Python_API#Compatibility
This change is in preparation of LTS releases, and also brings us more
in line with semantic versioning.
Fixes T76058.
Differential Revision: https://developer.blender.org/D7748
2020-05-25 10:49:04 +02:00
|
|
|
blender_version_init();
|
|
|
|
|
|
2002-10-12 11:37:38 +00:00
|
|
|
memset(&G, 0, sizeof(Global));
|
2018-06-17 17:05:51 +02:00
|
|
|
|
2012-05-06 17:22:54 +00:00
|
|
|
U.savetime = 1;
|
2002-10-12 11:37:38 +00:00
|
|
|
|
2022-10-05 12:55:32 +02:00
|
|
|
BKE_blender_globals_main_replace(BKE_main_new());
|
2002-10-12 11:37:38 +00:00
|
|
|
|
2023-10-05 13:33:37 +11:00
|
|
|
STRNCPY(G.filepath_last_image, "//");
|
2025-04-04 18:38:53 +02:00
|
|
|
G.filepath_last_blend[0] = '\0';
|
2002-10-12 11:37:38 +00:00
|
|
|
|
2011-04-28 06:20:47 +00:00
|
|
|
#ifndef WITH_PYTHON_SECURITY /* default */
|
2019-02-02 13:39:51 +11:00
|
|
|
G.f |= G_FLAG_SCRIPT_AUTOEXEC;
|
2011-04-28 06:20:47 +00:00
|
|
|
#else
|
2019-02-02 13:39:51 +11:00
|
|
|
G.f &= ~G_FLAG_SCRIPT_AUTOEXEC;
|
2011-04-28 06:20:47 +00:00
|
|
|
#endif
|
2018-03-29 20:38:32 +02:00
|
|
|
|
|
|
|
|
G.log.level = 1;
|
2025-02-18 15:36:50 +01:00
|
|
|
|
|
|
|
|
G.profile_gpu = false;
|
2002-10-12 11:37:38 +00:00
|
|
|
}
|
|
|
|
|
|
2023-07-18 14:18:07 +10:00
|
|
|
void BKE_blender_globals_clear()
|
2004-09-05 13:43:51 +00:00
|
|
|
{
|
2023-07-17 10:46:26 +02:00
|
|
|
if (G_MAIN == nullptr) {
|
2022-10-05 12:55:32 +02:00
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
BLI_assert(G_MAIN->is_global_main);
|
2018-06-13 10:57:10 +02:00
|
|
|
BKE_main_free(G_MAIN); /* free all lib data */
|
2002-10-12 11:37:38 +00:00
|
|
|
|
2023-07-17 10:46:26 +02:00
|
|
|
G_MAIN = nullptr;
|
2002-10-12 11:37:38 +00:00
|
|
|
}
|
|
|
|
|
|
2022-10-05 12:55:32 +02:00
|
|
|
void BKE_blender_globals_main_replace(Main *bmain)
|
|
|
|
|
{
|
|
|
|
|
BLI_assert(!bmain->is_global_main);
|
|
|
|
|
BKE_blender_globals_clear();
|
|
|
|
|
bmain->is_global_main = true;
|
|
|
|
|
G_MAIN = bmain;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
Main *BKE_blender_globals_main_swap(Main *new_gmain)
|
|
|
|
|
{
|
|
|
|
|
Main *old_gmain = G_MAIN;
|
|
|
|
|
BLI_assert(old_gmain->is_global_main);
|
|
|
|
|
BLI_assert(!new_gmain->is_global_main);
|
|
|
|
|
new_gmain->is_global_main = true;
|
|
|
|
|
G_MAIN = new_gmain;
|
|
|
|
|
old_gmain->is_global_main = false;
|
|
|
|
|
return old_gmain;
|
|
|
|
|
}
|
|
|
|
|
|
2025-04-04 18:38:53 +02:00
|
|
|
void BKE_blender_globals_crash_path_get(char filepath[FILE_MAX])
|
|
|
|
|
{
|
|
|
|
|
/* Might be called after WM/Main exit, so needs to be careful about nullptr-checking before
|
|
|
|
|
* de-referencing. */
|
|
|
|
|
|
|
|
|
|
if (!(G_MAIN && G_MAIN->filepath[0])) {
|
|
|
|
|
BLI_path_join(filepath, FILE_MAX, BKE_tempdir_base(), "blender.crash.txt");
|
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
BLI_path_join(filepath, FILE_MAX, BKE_tempdir_base(), BLI_path_basename(G_MAIN->filepath));
|
|
|
|
|
BLI_path_extension_replace(filepath, FILE_MAX, ".crash.txt");
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2020-09-17 15:34:10 +10:00
|
|
|
/** \} */
|
|
|
|
|
|
|
|
|
|
/* -------------------------------------------------------------------- */
|
|
|
|
|
/** \name Blender Preferences
|
|
|
|
|
* \{ */
|
2006-11-26 21:17:15 +00:00
|
|
|
|
KEYMAP REFACTORING
Diff Keymaps
User edited keymaps now no longer override the builtin keymaps entirely, but
rather save only the difference and reapply those changes. This means they can
stay better in sync when the builtin keymaps change. The diff/patch algorithm
is not perfect, but better for the common case where only a few items are changed
rather than entire keymaps The main weakness is that if a builtin keymap item
changes, user modification of that item may need to be redone in some cases.
Keymap Editor
The most noticeable change here is that there is no longer an "Edit" button for
keymaps, all are editable immediately, but a "Restore" buttons shows for keymaps
and items that have been edited. Shortcuts for addons can also be edited in the
keymap editor.
Addons
Addons now should only modify the new addon keyconfiguration, the keymap items
there will be added to the builtin ones for handling events, and not get lost
when starting new files. Example code of register/unregister:
km = wm.keyconfigs.addon.keymaps.new("3D View", space_type="VIEW_3D")
km.keymap_items.new('my.operator', 'ESC', 'PRESS')
km = wm.keyconfigs.addon.keymaps["3D View"]
km.keymap_items.remove(km.keymap_items["my.operator"])
Compatibility
The changes made are not forward compatible, i.e. if you save user preferences
with newer versions, older versions will not have key configuration changes that
were made.
2011-08-05 20:45:26 +00:00
|
|
|
static void keymap_item_free(wmKeyMapItem *kmi)
|
|
|
|
|
{
|
2012-03-24 06:18:31 +00:00
|
|
|
if (kmi->properties) {
|
KEYMAP REFACTORING
Diff Keymaps
User edited keymaps now no longer override the builtin keymaps entirely, but
rather save only the difference and reapply those changes. This means they can
stay better in sync when the builtin keymaps change. The diff/patch algorithm
is not perfect, but better for the common case where only a few items are changed
rather than entire keymaps The main weakness is that if a builtin keymap item
changes, user modification of that item may need to be redone in some cases.
Keymap Editor
The most noticeable change here is that there is no longer an "Edit" button for
keymaps, all are editable immediately, but a "Restore" buttons shows for keymaps
and items that have been edited. Shortcuts for addons can also be edited in the
keymap editor.
Addons
Addons now should only modify the new addon keyconfiguration, the keymap items
there will be added to the builtin ones for handling events, and not get lost
when starting new files. Example code of register/unregister:
km = wm.keyconfigs.addon.keymaps.new("3D View", space_type="VIEW_3D")
km.keymap_items.new('my.operator', 'ESC', 'PRESS')
km = wm.keyconfigs.addon.keymaps["3D View"]
km.keymap_items.remove(km.keymap_items["my.operator"])
Compatibility
The changes made are not forward compatible, i.e. if you save user preferences
with newer versions, older versions will not have key configuration changes that
were made.
2011-08-05 20:45:26 +00:00
|
|
|
IDP_FreeProperty(kmi->properties);
|
|
|
|
|
}
|
2019-04-22 09:39:35 +10:00
|
|
|
if (kmi->ptr) {
|
2024-08-29 15:09:42 +02:00
|
|
|
MEM_delete(kmi->ptr);
|
2019-04-22 09:39:35 +10:00
|
|
|
}
|
KEYMAP REFACTORING
Diff Keymaps
User edited keymaps now no longer override the builtin keymaps entirely, but
rather save only the difference and reapply those changes. This means they can
stay better in sync when the builtin keymaps change. The diff/patch algorithm
is not perfect, but better for the common case where only a few items are changed
rather than entire keymaps The main weakness is that if a builtin keymap item
changes, user modification of that item may need to be redone in some cases.
Keymap Editor
The most noticeable change here is that there is no longer an "Edit" button for
keymaps, all are editable immediately, but a "Restore" buttons shows for keymaps
and items that have been edited. Shortcuts for addons can also be edited in the
keymap editor.
Addons
Addons now should only modify the new addon keyconfiguration, the keymap items
there will be added to the builtin ones for handling events, and not get lost
when starting new files. Example code of register/unregister:
km = wm.keyconfigs.addon.keymaps.new("3D View", space_type="VIEW_3D")
km.keymap_items.new('my.operator', 'ESC', 'PRESS')
km = wm.keyconfigs.addon.keymaps["3D View"]
km.keymap_items.remove(km.keymap_items["my.operator"])
Compatibility
The changes made are not forward compatible, i.e. if you save user preferences
with newer versions, older versions will not have key configuration changes that
were made.
2011-08-05 20:45:26 +00:00
|
|
|
}
|
|
|
|
|
|
2017-11-23 03:10:58 +11:00
|
|
|
void BKE_blender_userdef_data_swap(UserDef *userdef_a, UserDef *userdef_b)
|
2017-03-17 05:10:36 +11:00
|
|
|
{
|
2023-07-17 10:46:26 +02:00
|
|
|
blender::dna::shallow_swap(*userdef_a, *userdef_b);
|
2017-11-23 03:10:58 +11:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void BKE_blender_userdef_data_set(UserDef *userdef)
|
|
|
|
|
{
|
|
|
|
|
BKE_blender_userdef_data_swap(&U, userdef);
|
|
|
|
|
BKE_blender_userdef_data_free(userdef, true);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void BKE_blender_userdef_data_set_and_free(UserDef *userdef)
|
|
|
|
|
{
|
|
|
|
|
BKE_blender_userdef_data_set(userdef);
|
|
|
|
|
MEM_freeN(userdef);
|
2017-03-17 05:10:36 +11:00
|
|
|
}
|
|
|
|
|
|
2017-03-20 12:42:19 +11:00
|
|
|
static void userdef_free_keymaps(UserDef *userdef)
|
2009-04-30 16:44:00 +00:00
|
|
|
{
|
2023-07-17 10:46:26 +02:00
|
|
|
for (wmKeyMap *km = static_cast<wmKeyMap *>(userdef->user_keymaps.first), *km_next; km;
|
|
|
|
|
km = km_next)
|
|
|
|
|
{
|
2017-03-20 12:42:19 +11:00
|
|
|
km_next = km->next;
|
2020-04-03 19:15:01 +02:00
|
|
|
LISTBASE_FOREACH (wmKeyMapDiffItem *, kmdi, &km->diff_items) {
|
2012-03-24 06:18:31 +00:00
|
|
|
if (kmdi->add_item) {
|
KEYMAP REFACTORING
Diff Keymaps
User edited keymaps now no longer override the builtin keymaps entirely, but
rather save only the difference and reapply those changes. This means they can
stay better in sync when the builtin keymaps change. The diff/patch algorithm
is not perfect, but better for the common case where only a few items are changed
rather than entire keymaps The main weakness is that if a builtin keymap item
changes, user modification of that item may need to be redone in some cases.
Keymap Editor
The most noticeable change here is that there is no longer an "Edit" button for
keymaps, all are editable immediately, but a "Restore" buttons shows for keymaps
and items that have been edited. Shortcuts for addons can also be edited in the
keymap editor.
Addons
Addons now should only modify the new addon keyconfiguration, the keymap items
there will be added to the builtin ones for handling events, and not get lost
when starting new files. Example code of register/unregister:
km = wm.keyconfigs.addon.keymaps.new("3D View", space_type="VIEW_3D")
km.keymap_items.new('my.operator', 'ESC', 'PRESS')
km = wm.keyconfigs.addon.keymaps["3D View"]
km.keymap_items.remove(km.keymap_items["my.operator"])
Compatibility
The changes made are not forward compatible, i.e. if you save user preferences
with newer versions, older versions will not have key configuration changes that
were made.
2011-08-05 20:45:26 +00:00
|
|
|
keymap_item_free(kmdi->add_item);
|
|
|
|
|
MEM_freeN(kmdi->add_item);
|
|
|
|
|
}
|
2012-03-24 06:18:31 +00:00
|
|
|
if (kmdi->remove_item) {
|
KEYMAP REFACTORING
Diff Keymaps
User edited keymaps now no longer override the builtin keymaps entirely, but
rather save only the difference and reapply those changes. This means they can
stay better in sync when the builtin keymaps change. The diff/patch algorithm
is not perfect, but better for the common case where only a few items are changed
rather than entire keymaps The main weakness is that if a builtin keymap item
changes, user modification of that item may need to be redone in some cases.
Keymap Editor
The most noticeable change here is that there is no longer an "Edit" button for
keymaps, all are editable immediately, but a "Restore" buttons shows for keymaps
and items that have been edited. Shortcuts for addons can also be edited in the
keymap editor.
Addons
Addons now should only modify the new addon keyconfiguration, the keymap items
there will be added to the builtin ones for handling events, and not get lost
when starting new files. Example code of register/unregister:
km = wm.keyconfigs.addon.keymaps.new("3D View", space_type="VIEW_3D")
km.keymap_items.new('my.operator', 'ESC', 'PRESS')
km = wm.keyconfigs.addon.keymaps["3D View"]
km.keymap_items.remove(km.keymap_items["my.operator"])
Compatibility
The changes made are not forward compatible, i.e. if you save user preferences
with newer versions, older versions will not have key configuration changes that
were made.
2011-08-05 20:45:26 +00:00
|
|
|
keymap_item_free(kmdi->remove_item);
|
|
|
|
|
MEM_freeN(kmdi->remove_item);
|
Key Configuration
Keymaps are now saveable and configurable from the user preferences, note
that editing one item in a keymap means the whole keymap is now defined by
the user and will not be updated by Blender, an option for syncing might be
added later. The outliner interface is still there, but I will probably
remove it.
There's actually 3 levels now:
* Default builtin key configuration.
* Key configuration loaded from .py file, for configs like Blender 2.4x
or other 3D applications.
* Keymaps edited by the user and saved in .B.blend. These can be saved
to .py files as well to make creating distributable configurations
easier.
Also, user preferences sections were reorganized a bit, now there is:
Interface, Editing, Input, Files and System.
Implementation notes:
* wmKeyConfig was added which represents a key configuration containing
keymaps.
* wmKeymapItem was renamed to wmKeyMapItem for consistency with wmKeyMap.
* Modal maps are not wrapped yet.
* User preferences DNA file reading did not support newdataadr() yet,
added this now for reading keymaps.
* Key configuration related settings are now RNA wrapped.
* is_property_set and is_property_hidden python methods were added.
2009-10-08 18:40:03 +00:00
|
|
|
}
|
|
|
|
|
}
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2020-04-03 19:15:01 +02:00
|
|
|
LISTBASE_FOREACH (wmKeyMapItem *, kmi, &km->items) {
|
KEYMAP REFACTORING
Diff Keymaps
User edited keymaps now no longer override the builtin keymaps entirely, but
rather save only the difference and reapply those changes. This means they can
stay better in sync when the builtin keymaps change. The diff/patch algorithm
is not perfect, but better for the common case where only a few items are changed
rather than entire keymaps The main weakness is that if a builtin keymap item
changes, user modification of that item may need to be redone in some cases.
Keymap Editor
The most noticeable change here is that there is no longer an "Edit" button for
keymaps, all are editable immediately, but a "Restore" buttons shows for keymaps
and items that have been edited. Shortcuts for addons can also be edited in the
keymap editor.
Addons
Addons now should only modify the new addon keyconfiguration, the keymap items
there will be added to the builtin ones for handling events, and not get lost
when starting new files. Example code of register/unregister:
km = wm.keyconfigs.addon.keymaps.new("3D View", space_type="VIEW_3D")
km.keymap_items.new('my.operator', 'ESC', 'PRESS')
km = wm.keyconfigs.addon.keymaps["3D View"]
km.keymap_items.remove(km.keymap_items["my.operator"])
Compatibility
The changes made are not forward compatible, i.e. if you save user preferences
with newer versions, older versions will not have key configuration changes that
were made.
2011-08-05 20:45:26 +00:00
|
|
|
keymap_item_free(kmi);
|
2017-03-17 00:18:20 +11:00
|
|
|
}
|
2019-04-17 06:17:24 +02:00
|
|
|
|
KEYMAP REFACTORING
Diff Keymaps
User edited keymaps now no longer override the builtin keymaps entirely, but
rather save only the difference and reapply those changes. This means they can
stay better in sync when the builtin keymaps change. The diff/patch algorithm
is not perfect, but better for the common case where only a few items are changed
rather than entire keymaps The main weakness is that if a builtin keymap item
changes, user modification of that item may need to be redone in some cases.
Keymap Editor
The most noticeable change here is that there is no longer an "Edit" button for
keymaps, all are editable immediately, but a "Restore" buttons shows for keymaps
and items that have been edited. Shortcuts for addons can also be edited in the
keymap editor.
Addons
Addons now should only modify the new addon keyconfiguration, the keymap items
there will be added to the builtin ones for handling events, and not get lost
when starting new files. Example code of register/unregister:
km = wm.keyconfigs.addon.keymaps.new("3D View", space_type="VIEW_3D")
km.keymap_items.new('my.operator', 'ESC', 'PRESS')
km = wm.keyconfigs.addon.keymaps["3D View"]
km.keymap_items.remove(km.keymap_items["my.operator"])
Compatibility
The changes made are not forward compatible, i.e. if you save user preferences
with newer versions, older versions will not have key configuration changes that
were made.
2011-08-05 20:45:26 +00:00
|
|
|
BLI_freelistN(&km->diff_items);
|
Key Configuration
Keymaps are now saveable and configurable from the user preferences, note
that editing one item in a keymap means the whole keymap is now defined by
the user and will not be updated by Blender, an option for syncing might be
added later. The outliner interface is still there, but I will probably
remove it.
There's actually 3 levels now:
* Default builtin key configuration.
* Key configuration loaded from .py file, for configs like Blender 2.4x
or other 3D applications.
* Keymaps edited by the user and saved in .B.blend. These can be saved
to .py files as well to make creating distributable configurations
easier.
Also, user preferences sections were reorganized a bit, now there is:
Interface, Editing, Input, Files and System.
Implementation notes:
* wmKeyConfig was added which represents a key configuration containing
keymaps.
* wmKeymapItem was renamed to wmKeyMapItem for consistency with wmKeyMap.
* Modal maps are not wrapped yet.
* User preferences DNA file reading did not support newdataadr() yet,
added this now for reading keymaps.
* Key configuration related settings are now RNA wrapped.
* is_property_set and is_property_hidden python methods were added.
2009-10-08 18:40:03 +00:00
|
|
|
BLI_freelistN(&km->items);
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2017-03-20 12:42:19 +11:00
|
|
|
MEM_freeN(km);
|
Key Configuration
Keymaps are now saveable and configurable from the user preferences, note
that editing one item in a keymap means the whole keymap is now defined by
the user and will not be updated by Blender, an option for syncing might be
added later. The outliner interface is still there, but I will probably
remove it.
There's actually 3 levels now:
* Default builtin key configuration.
* Key configuration loaded from .py file, for configs like Blender 2.4x
or other 3D applications.
* Keymaps edited by the user and saved in .B.blend. These can be saved
to .py files as well to make creating distributable configurations
easier.
Also, user preferences sections were reorganized a bit, now there is:
Interface, Editing, Input, Files and System.
Implementation notes:
* wmKeyConfig was added which represents a key configuration containing
keymaps.
* wmKeymapItem was renamed to wmKeyMapItem for consistency with wmKeyMap.
* Modal maps are not wrapped yet.
* User preferences DNA file reading did not support newdataadr() yet,
added this now for reading keymaps.
* Key configuration related settings are now RNA wrapped.
* is_property_set and is_property_hidden python methods were added.
2009-10-08 18:40:03 +00:00
|
|
|
}
|
2017-03-20 12:42:19 +11:00
|
|
|
BLI_listbase_clear(&userdef->user_keymaps);
|
|
|
|
|
}
|
2017-03-17 00:18:20 +11:00
|
|
|
|
2018-11-16 11:24:49 +11:00
|
|
|
static void userdef_free_keyconfig_prefs(UserDef *userdef)
|
|
|
|
|
{
|
2023-07-17 10:46:26 +02:00
|
|
|
for (wmKeyConfigPref *kpt = static_cast<wmKeyConfigPref *>(userdef->user_keyconfig_prefs.first),
|
|
|
|
|
*kpt_next;
|
|
|
|
|
kpt;
|
|
|
|
|
kpt = kpt_next)
|
2018-11-19 06:14:20 +11:00
|
|
|
{
|
2018-11-16 11:24:49 +11:00
|
|
|
kpt_next = kpt->next;
|
|
|
|
|
IDP_FreeProperty(kpt->prop);
|
|
|
|
|
MEM_freeN(kpt);
|
|
|
|
|
}
|
|
|
|
|
BLI_listbase_clear(&userdef->user_keyconfig_prefs);
|
|
|
|
|
}
|
|
|
|
|
|
2018-06-24 16:07:34 +02:00
|
|
|
static void userdef_free_user_menus(UserDef *userdef)
|
|
|
|
|
{
|
2023-07-17 10:46:26 +02:00
|
|
|
for (bUserMenu *um = static_cast<bUserMenu *>(userdef->user_menus.first), *um_next; um;
|
|
|
|
|
um = um_next)
|
|
|
|
|
{
|
2018-06-24 16:07:34 +02:00
|
|
|
um_next = um->next;
|
|
|
|
|
BKE_blender_user_menu_item_free_list(&um->items);
|
|
|
|
|
MEM_freeN(um);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2017-03-20 12:42:19 +11:00
|
|
|
static void userdef_free_addons(UserDef *userdef)
|
|
|
|
|
{
|
2023-07-17 10:46:26 +02:00
|
|
|
for (bAddon *addon = static_cast<bAddon *>(userdef->addons.first), *addon_next; addon;
|
|
|
|
|
addon = addon_next)
|
|
|
|
|
{
|
2012-12-29 10:24:42 +00:00
|
|
|
addon_next = addon->next;
|
2018-02-12 17:24:18 +11:00
|
|
|
BKE_addon_free(addon);
|
2012-12-29 10:24:42 +00:00
|
|
|
}
|
2017-03-20 12:42:19 +11:00
|
|
|
BLI_listbase_clear(&userdef->addons);
|
|
|
|
|
}
|
|
|
|
|
|
2017-11-23 03:10:58 +11:00
|
|
|
void BKE_blender_userdef_data_free(UserDef *userdef, bool clear_fonts)
|
2017-03-20 12:42:19 +11:00
|
|
|
{
|
2020-09-17 15:23:23 +10:00
|
|
|
#define U BLI_STATIC_ASSERT(false, "Global 'U' not allowed, only use arguments passed in!")
|
2023-12-07 10:39:03 +11:00
|
|
|
#ifdef U
|
|
|
|
|
/* Quiet warning. */
|
2017-03-20 12:42:19 +11:00
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
userdef_free_keymaps(userdef);
|
2018-11-16 11:24:49 +11:00
|
|
|
userdef_free_keyconfig_prefs(userdef);
|
2018-06-24 16:07:34 +02:00
|
|
|
userdef_free_user_menus(userdef);
|
2017-03-20 12:42:19 +11:00
|
|
|
userdef_free_addons(userdef);
|
2014-06-14 02:23:32 +10:00
|
|
|
|
2017-03-17 00:18:20 +11:00
|
|
|
if (clear_fonts) {
|
2020-04-03 19:15:01 +02:00
|
|
|
LISTBASE_FOREACH (uiFont *, font, &userdef->uifonts) {
|
2017-11-23 03:10:58 +11:00
|
|
|
BLF_unload_id(font->blf_id);
|
2019-04-17 06:17:24 +02:00
|
|
|
}
|
2017-03-17 00:18:20 +11:00
|
|
|
BLF_default_set(-1);
|
2019-04-17 06:17:24 +02:00
|
|
|
}
|
2017-03-17 00:18:20 +11:00
|
|
|
|
|
|
|
|
BLI_freelistN(&userdef->autoexec_paths);
|
2023-04-11 15:20:52 +02:00
|
|
|
BLI_freelistN(&userdef->script_directories);
|
2020-12-14 13:39:41 +01:00
|
|
|
BLI_freelistN(&userdef->asset_libraries);
|
2024-05-22 20:32:23 +10:00
|
|
|
|
|
|
|
|
LISTBASE_FOREACH_MUTABLE (bUserExtensionRepo *, repo_ref, &userdef->extension_repos) {
|
|
|
|
|
MEM_SAFE_FREE(repo_ref->access_token);
|
|
|
|
|
MEM_freeN(repo_ref);
|
|
|
|
|
}
|
2024-05-22 20:09:35 +02:00
|
|
|
BLI_listbase_clear(&userdef->extension_repos);
|
2024-05-22 20:32:23 +10:00
|
|
|
|
2024-05-03 10:20:01 -04:00
|
|
|
LISTBASE_FOREACH_MUTABLE (bUserAssetShelfSettings *, settings, &userdef->asset_shelves_settings)
|
|
|
|
|
{
|
|
|
|
|
BKE_asset_catalog_path_list_free(settings->enabled_catalog_paths);
|
|
|
|
|
MEM_freeN(settings);
|
|
|
|
|
}
|
|
|
|
|
BLI_listbase_clear(&userdef->asset_shelves_settings);
|
2013-06-18 18:11:52 +00:00
|
|
|
|
2017-03-17 00:18:20 +11:00
|
|
|
BLI_freelistN(&userdef->uistyles);
|
|
|
|
|
BLI_freelistN(&userdef->uifonts);
|
|
|
|
|
BLI_freelistN(&userdef->themes);
|
2018-06-23 16:31:28 +02:00
|
|
|
|
2017-03-17 00:18:20 +11:00
|
|
|
#undef U
|
2009-04-30 16:44:00 +00:00
|
|
|
}
|
|
|
|
|
|
2020-09-17 15:34:10 +10:00
|
|
|
/** \} */
|
|
|
|
|
|
|
|
|
|
/* -------------------------------------------------------------------- */
|
|
|
|
|
/** \name Blender Preferences (Application Templates)
|
|
|
|
|
* \{ */
|
|
|
|
|
|
2017-11-23 03:10:58 +11:00
|
|
|
void BKE_blender_userdef_app_template_data_swap(UserDef *userdef_a, UserDef *userdef_b)
|
2017-03-25 09:29:51 +11:00
|
|
|
{
|
|
|
|
|
/* TODO:
|
|
|
|
|
* - various minor settings (add as needed).
|
|
|
|
|
*/
|
|
|
|
|
|
2024-02-16 14:26:45 +11:00
|
|
|
#define VALUE_SWAP(id) \
|
|
|
|
|
{ \
|
|
|
|
|
std::swap(userdef_a->id, userdef_b->id); \
|
|
|
|
|
}
|
|
|
|
|
|
2017-11-23 03:10:58 +11:00
|
|
|
#define DATA_SWAP(id) \
|
2017-11-23 15:18:22 +11:00
|
|
|
{ \
|
|
|
|
|
UserDef userdef_tmp; \
|
|
|
|
|
memcpy(&(userdef_tmp.id), &(userdef_a->id), sizeof(userdef_tmp.id)); \
|
|
|
|
|
memcpy(&(userdef_a->id), &(userdef_b->id), sizeof(userdef_tmp.id)); \
|
|
|
|
|
memcpy(&(userdef_b->id), &(userdef_tmp.id), sizeof(userdef_tmp.id)); \
|
2019-04-02 17:54:04 +11:00
|
|
|
} \
|
|
|
|
|
((void)0)
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2018-01-11 16:08:55 +11:00
|
|
|
#define FLAG_SWAP(id, ty, flags) \
|
|
|
|
|
{ \
|
|
|
|
|
CHECK_TYPE(&(userdef_a->id), ty *); \
|
|
|
|
|
const ty f = flags; \
|
|
|
|
|
const ty a = userdef_a->id; \
|
|
|
|
|
const ty b = userdef_b->id; \
|
2018-01-16 11:40:43 +11:00
|
|
|
userdef_a->id = (userdef_a->id & ~f) | (b & f); \
|
|
|
|
|
userdef_b->id = (userdef_b->id & ~f) | (a & f); \
|
2018-01-11 16:08:55 +11:00
|
|
|
} \
|
|
|
|
|
((void)0)
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2024-02-16 14:26:45 +11:00
|
|
|
VALUE_SWAP(uistyles);
|
|
|
|
|
VALUE_SWAP(uifonts);
|
|
|
|
|
VALUE_SWAP(themes);
|
|
|
|
|
VALUE_SWAP(addons);
|
|
|
|
|
VALUE_SWAP(user_keymaps);
|
|
|
|
|
VALUE_SWAP(user_keyconfig_prefs);
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2017-11-23 03:10:58 +11:00
|
|
|
DATA_SWAP(font_path_ui);
|
|
|
|
|
DATA_SWAP(font_path_ui_mono);
|
2018-01-04 14:07:45 +11:00
|
|
|
DATA_SWAP(keyconfigstr);
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2018-07-14 23:49:00 +02:00
|
|
|
DATA_SWAP(gizmo_flag);
|
2018-01-12 12:30:58 +11:00
|
|
|
DATA_SWAP(app_flag);
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2018-01-12 12:30:58 +11:00
|
|
|
/* We could add others. */
|
2021-09-13 15:57:17 +02:00
|
|
|
FLAG_SWAP(uiflag, int, USER_SAVE_PROMPT | USER_SPLASH_DISABLE | USER_SHOW_GIZMO_NAVIGATE);
|
|
|
|
|
|
|
|
|
|
DATA_SWAP(ui_scale);
|
2018-01-11 16:08:55 +11:00
|
|
|
|
2024-02-16 14:26:45 +11:00
|
|
|
#undef VALUE_SWAP
|
2017-11-23 03:10:58 +11:00
|
|
|
#undef DATA_SWAP
|
2018-01-11 16:08:55 +11:00
|
|
|
#undef FLAG_SWAP
|
2017-11-23 03:10:58 +11:00
|
|
|
}
|
2017-03-25 09:29:51 +11:00
|
|
|
|
2017-11-23 03:10:58 +11:00
|
|
|
void BKE_blender_userdef_app_template_data_set(UserDef *userdef)
|
|
|
|
|
{
|
|
|
|
|
BKE_blender_userdef_app_template_data_swap(&U, userdef);
|
|
|
|
|
BKE_blender_userdef_data_free(userdef, true);
|
|
|
|
|
}
|
2017-03-25 09:29:51 +11:00
|
|
|
|
2017-11-23 03:10:58 +11:00
|
|
|
void BKE_blender_userdef_app_template_data_set_and_free(UserDef *userdef)
|
|
|
|
|
{
|
|
|
|
|
BKE_blender_userdef_app_template_data_set(userdef);
|
|
|
|
|
MEM_freeN(userdef);
|
2017-03-25 09:29:51 +11:00
|
|
|
}
|
|
|
|
|
|
2020-09-17 15:34:10 +10:00
|
|
|
/** \} */
|
|
|
|
|
|
|
|
|
|
/* -------------------------------------------------------------------- */
|
2016-06-24 10:05:18 +10:00
|
|
|
/** \name Blender's AtExit
|
|
|
|
|
*
|
|
|
|
|
* \note Don't use MEM_mallocN so functions can be registered at any time.
|
|
|
|
|
* \{ */
|
|
|
|
|
|
2017-02-06 17:42:30 +01:00
|
|
|
static struct AtExitData {
|
2023-07-20 11:30:25 +10:00
|
|
|
AtExitData *next;
|
2016-06-24 10:05:18 +10:00
|
|
|
|
|
|
|
|
void (*func)(void *user_data);
|
|
|
|
|
void *user_data;
|
2023-07-17 10:46:26 +02:00
|
|
|
} *g_atexit = nullptr;
|
2016-06-24 10:05:18 +10:00
|
|
|
|
|
|
|
|
void BKE_blender_atexit_register(void (*func)(void *user_data), void *user_data)
|
|
|
|
|
{
|
2023-07-20 11:30:25 +10:00
|
|
|
AtExitData *ae = static_cast<AtExitData *>(malloc(sizeof(*ae)));
|
2016-06-24 10:05:18 +10:00
|
|
|
ae->next = g_atexit;
|
|
|
|
|
ae->func = func;
|
|
|
|
|
ae->user_data = user_data;
|
|
|
|
|
g_atexit = ae;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void BKE_blender_atexit_unregister(void (*func)(void *user_data), const void *user_data)
|
|
|
|
|
{
|
2023-07-20 11:30:25 +10:00
|
|
|
AtExitData *ae = g_atexit;
|
|
|
|
|
AtExitData **ae_p = &g_atexit;
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2016-06-24 10:05:18 +10:00
|
|
|
while (ae) {
|
|
|
|
|
if ((ae->func == func) && (ae->user_data == user_data)) {
|
|
|
|
|
*ae_p = ae->next;
|
|
|
|
|
free(ae);
|
|
|
|
|
return;
|
|
|
|
|
}
|
2021-01-07 13:22:28 +11:00
|
|
|
ae_p = &ae->next;
|
2016-06-24 10:05:18 +10:00
|
|
|
ae = ae->next;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2023-07-18 14:18:07 +10:00
|
|
|
void BKE_blender_atexit()
|
2016-06-24 10:05:18 +10:00
|
|
|
{
|
2023-07-20 11:30:25 +10:00
|
|
|
AtExitData *ae = g_atexit, *ae_next;
|
2016-06-24 10:05:18 +10:00
|
|
|
while (ae) {
|
|
|
|
|
ae_next = ae->next;
|
|
|
|
|
|
|
|
|
|
ae->func(ae->user_data);
|
|
|
|
|
|
|
|
|
|
free(ae);
|
|
|
|
|
ae = ae_next;
|
|
|
|
|
}
|
2023-07-17 10:46:26 +02:00
|
|
|
g_atexit = nullptr;
|
2016-06-24 10:05:18 +10:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/** \} */
|