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
AgeCommit message (Collapse)Author
2022-08-23Fix T100286: Crash accessing freed depsgraph object instancesCampbell Barton
Invalidate depsgraph.object_instances when freed, this resolves a crash when accessing the object instances after iteration has finished. Unlike most other collections, object_instances is only valid while the iterator is in-memory. The Python/RNA API needs to inline int/string collection lookups so the Python instance can be created before the iterator ends. Reviewed By: mont29, sergey Ref D15755
2022-08-19Fix crash accessing PyEval_GetFrame from Python's crash handlerCampbell Barton
Check the thread-state before accessing PyEval_GetFrame, since this is a crash handler, the state of the Python interpreter isn't known.
2022-08-04Cleanup: Move RNA path functions into own C++ fileJulian Eisel
NOTE: This is committed to the 3.3 branch as part of D15606, which we decided should go to this release still (by Bastien, Dalai and me). That is because these are important usability fixes/improvements to have for the LTS release. Adds `rna_path.cc` and `RNA_path.h`. `rna_access.c` is a quite big file, which makes it rather hard and inconvenient to navigate. RNA path functions form a nicely coherent unit that can stand well on it's own, so it makes sense to split them off to mitigate the problem. Moreover, I was looking into refactoring the quite convoluted/overloaded `rna_path_parse()`, and found that some C++ features may help greatly with that. So having that code compile in C++ would be helpful to attempt that. Differential Revision: https://developer.blender.org/D15540 Reviewed by: Brecht Van Lommel, Campbell Barton, Bastien Montagne
2022-07-16PyAPI: re-enable the "bgl" module for headless buildsCampbell Barton
Instead of removing the `bgl` module, set all it's functions to stubs so importing `bgl` or any of it's members doesn't raise an error. This avoids problems for scripts that import bgl but don't call it's functions when running in background mode.
2022-07-15Fix T99706: Crash rendering with headless buildsCampbell Barton
When rendering with headless builds, show an error instead of crashing. Previously GPU_backend_init was called indirectly from DRW_opengl_context_create, a new function is now called from the window manager (GPU_backend_init_once), so it's possible to check if the GPU has a back-end. This also disables the `bgl` Python module when building WITH_HEADLESS. Reviewed By: fclem Ref D15463
2022-07-14Cleanup: Rename & refactor several F-curve functionsColin Basnett
Rename and refactor several F-curve key manipulation functions, and move them from `editors` to `blenkernel`. The functions formerly known as `delete_fcurve_key`, `delete_fcurve_keys`, and `clear_fcurve_keys` have been moved from `ED_keyframes_edit.h` to `BKE_fcurve.h` and have been renamed according to hierarchical naming rules. Below is a table of the naming changes. | From | To | | -- | -- | | `delete_fcurve_key(fcu, index, do_recalc)` | `BKE_fcurve_delete_key(fcu, index)` | | `delete_fcurve_keys(fcu)` | `BKE_fcurve_delete_keys_selected(fcu)` | | `clear_fcurve_keys(fcu)` | `BKE_fcurve_delete_keys_all(fcu)` | | `calchandles_fcurve()` | `BKE_fcurve_handles_recalc()` | | `calchandles_fcurve_ex()`| `BKE_fcurve_handles_recalc_ex()` | The function formerly known as `delete_fcurve_key` no longer takes a `do_fast` parameter, which determined whether or not to call `calchandles_fcurve`. Now, the responsibility is on the caller to run the new `BKE_fcurve_handles_recalc` function if they have want to recalculate the handles. In addition, there is now a new static private function called `fcurve_bezt_free` which sets the key count to zero and frees the key array. This function is now used in couple of instances of functionally equivalent code. Note that `BKE_fcurve_delete_keys_all` is just a wrapper around `fcurve_bezt_free`. This change was initially spurred by the fact that `delete_fcurve_keys` was improperly named; this was a good opportunity to fix the location and naming of a few of these functions. Reviewed By: sybren Differential Revision: https://developer.blender.org/D15282
2022-07-13Documentation: Update Docs for Gizmojon denning
This patch updates the documentation for arguments regarding the `Gizmo` type. - Corrected `select_id` doc for draw_preset_ functions. `-1` indicates that no selection ID is to be written, but previous docs incorrectly specified `0` instead. - Added missing doc for `target` argument for `target_set_handler` function. Reviewed by: Aaron Carlisle (Blendify) Differential Revision: https://developer.blender.org/D14834
2022-07-12Cleanup: use array for internal _bpy methodsCampbell Barton
2022-07-12Tests: add test to ensure restricted py-driver execution is workingCampbell Barton
Add internal function (only used for testing at the moment) `_bpy._driver_secure_code_test`. Add test `script_pyapi_bpy_driver_secure_eval` to serves two purposes: - Ensure expressions that should be insecure remain so when upgrading Python or making any changes in this area. - Ensure new versions of Python don't introduce new byte-codes that prevent existing expressions from being executed (happened when upgrading from 3.7, see [0]). [0]: dfa52017638abdf59791e5588c439d3a558a191d
2022-07-12Python: add opcodes for safe py-driversCampbell Barton
The following opcodes have been added, see [0] for details: - LIST_TO_TUPLE: convert a list to a tuple, use for constructing lists/tuples in some cases. - LIST_EXTEND: use for constructing lists with unpacking. - SET_UPDATE: use for constructing sets with unpacking. - CONTAINS_OP: check if `a in b` generally useful. When writing tests these op-codes where needed for basic operations and can be safely supported. Add note why dictionary manipulation op-codes have been left out. Also restrict namsepace access to anything with an underscore prefix since these may be undocumented. [0]: https://docs.python.org/3.10/library/dis.html
2022-07-08Cleanup: spelling in commentsCampbell Barton
Also move mis-placed doc-string.
2022-07-07Python: show additional context for PyDriver errors in the stderrCampbell Barton
Showing the expression alone may not be enough to track down an error evaluating a py-driver. Show information about the target ID & property in the error message as well.
2022-07-07Python: clear Py-driver variables on exitCampbell Barton
These kinds of leaks are relatively harmless, it reduces the number of un-freed data reported by valgrind on exit.
2022-07-07Cleanup: use boolean types & early exit on failure for PyDriverCampbell Barton
Also use __func__ for printing the funciton name.
2022-07-07Fix Py-driver byte code access with Python 3.11Campbell Barton
Error in [0] which assumed the struct member was renamed however byte-code access from PyCodeObject now requires an API call. Thanks to @music for pointing this out. [0]: 780c0ea097444c3be60314dffd203c099720badb
2022-07-05Python: support v3.11 (beta) with changes to PyFrameObject & opcodesCampbell Barton
- Use API calls to access frame-data as PyFrameObject is now opaque. - Update opcodes allowed for safe driver evaluation. **Details** Some opcodes have been added for safe-driver evaluation. Python 3.11 removes many opcodes - the number of accepted opcodes in Blender's listing dropped from 65 to 43) however some new opcodes also needed to be added. As this relates to security details about newly added opcodes have been noted below (see [0] for full documentation). Newly added opcodes: - CACHE: Used to control caching instructions. - RESUME: A no-op. Performs internal checks. - BINARY_OP: Implements the binary and in-place operators, replacing specific binary operations. - CALL, PRECALL, KW_NAMES: Used for calling functions, replacing some existing opcodes. - POP_JUMP_{FORWARD/BACKWARD}_IF_{TRUE/FALSE/NONE/NOT_NONE}. Manipulate the byte-code counter. - SWAP, PUSH_NULL. Stack manipulation. Resolves T99277. [0]: https://docs.python.org/3.11/library/dis.html
2022-07-05Python: add opcodes for safe py-driversCampbell Barton
New opcodes added since 3.7 meant some actions such as `len()` were disabled in safe py-driver execution. The following opcodes have been added, see [0] for details: - ROT_FOUR: similar to existing ROT_* opcodes, added v3.8. - ROT_N: similar to existing ROT_* opcodes, added v3.10. - GET_LEN: Push len(TOS) onto the stack, added v3.10. - IS_OP: for ternary operator, added v3.9. - BUILD_SLICE: access `slice` built-in, doesn't expose new functionality beyond existing `__getitem__` access. [0]: https://docs.python.org/3.10/library/dis.html
2022-07-05Python: remove invalid Py_TPFLAGS_HAVE_GC usageCampbell Barton
Blender wouldn't start with Python 3.11 because of an error in Py_TPFLAGS_HAVE_GC usage for `bpy.app.handlers.persistent`. Remove this flag as it's not necessary. Part of fix for T99277.
2022-06-13Cleanup: fix various typosBrecht Van Lommel
Found via codespell -q 3 -S ./intern,./extern -L ans,ba,bording,datas,eiter,fiter,hist,inout,lod,ot,parm,parms,pixelx,pres,te Contributed by luzpaz. Differential Revision: https://developer.blender.org/D15155
2022-06-08CMake: optionally disable OBJ, STL & GPencil SVG supportCampbell Barton
The following CMake options have been added (enabled by default), except for the lite build configuration. - WITH_IO_STL - WITH_IO_WAVEFRONT_OBJ - WITH_IO_GPENCIL (for grease pencil SVG importing). Note that it was already possible to disable grease pencil export by disabling WITH_PUGIXML & WITH_HARU. This is intended to keep the lite builds fast and small for building, linking & execution. Reviewed By: iyadahmed2001, aras_p, antoniov, mont29 Ref D15141
2022-06-03Compositor: add pre/post/cancel handlers and background job infoPhilipp Oeser
Main motivation is from T54314 where there was no way to read from a Viewer image datablock after the compositor has run. The only solution there was to do a full rerender (which obviously takes much longer). Adding a handler avoids having to rerender. This uses new syntax from rBf4456a4d3c97 and also adds "COMPOSITE" as a job type that can be queried by `bpy.app.is_job_running`. NOTE: there is another issue when multiple viewers are used and these get active via RNA (compo execution is not triggered there yet -- unlike when a viewer is selected in the Editor -- this is an issue of `ED_node_set_active` vs. only `nodeSetActive`, but this will be tackled separately) Maniphest Tasks: T54314 Differential Revision: https://developer.blender.org/D15078
2022-06-02PyDoc: reference enum instead of inliningCampbell Barton
2022-06-02Expose background job info to PythonSybren A. Stüvel
Add `bpy.app.is_job_running(job_type)` as high-level indicator. Job types currently exposed are `WM_JOB_TYPE_RENDER`, `WM_JOB_TYPE_RENDER_PREVIEW`, and `WM_JOB_TYPE_OBJECT_BAKE`, as strings with the `WM_JOB_TYPE_` prefix removed. The functions can be polled by Python code to determine whether such background work is still ongoing or not. Furthermore, new app handles are added for `object_bake_{pre,complete,canceled}`, which are called respectively before an object baking job starts, completes sucessfully, and stops due to a cancellation. Motivation: There are various cases where Python can trigger the execution of a background job, without getting notification that that background job is done. As a result, it's hard to do things like cleanups, or auto-quitting Blender after the work is done. The approach in this commit can easily be extended with other job types, when the need arises. The rendering of asset previews is one that's likely to be added sooner than later, as there have already been requests about this. Reviewed By: campbellbarton Differential Revision: https://developer.blender.org/D14587
2022-05-31Cleanup: tabs to spaces for CMake files & sort file-listsCampbell Barton
2022-05-31PyDoc: de-duplicate enums for rna_rna.c & bpy_props.cCampbell Barton
Lists of items for bpy.props were duplicated 3 times, now all enums are defined once in rna_rna.c and referenced from bpy.props doc-strings.
2022-05-31PyAPI: add _bpy.rna_enum_items_static() for accessing internal enum dataCampbell Barton
This is method is intended for internal use (introspection for generating API docs).
2022-05-27Fix error checking the search callbackCampbell Barton
Error in [0] caused the `set` callback be checked as the search callback. [0]: 3f3d82cfe9cefe4bfd9da3d283dec4a1923ec22d
2022-05-26UI support for showing candidates for string propertiesCampbell Barton
Currently strings are used for cases where a list of identifiers would be useful to show. Add support for string properties to reference a callback to populate candidates to show when editing a string. The user isn't prevented from typing in text not found in this list, it's just useful as a reference. Support for expanding the following strings has been added: - Operator, menu & panel identifiers in the keymap editor. - WM operators that reference data-paths expand using the Python-consoles auto-complete functionality. - Names of keying sets for insert/delete keyframe operators. Details: - `bpy.props.StringProperty` takes an option `search` callback. - A new string callback has been added, set via `RNA_def_property_string_search_func` or `RNA_def_property_string_search_func_runtime`. - Addresses usability issue highlighted by T89560, where setting keying set identifiers as strings isn't practical. - Showing additional right-aligned text in the search results is supported but disabled by default as the text is too cramped in most string search popups where the feature would make sense. It could be enabled as part of other layout tweaks. Reviewed By: brecht Ref D14986
2022-05-20CMake: fix AUDASPACE disabling WITH_PYTHON for BlenderCampbell Barton
When AUDASPACE couldn't find NUMPY, it would disable WITH_PYTHON for the rest of Blender. Now setting the value globally is only done for standalone AUDASPACE builds. Now it's possible to build Blender with AUDASPACE & PYTHON but without NUMPY. While this isn't an especially important configuration to support, having Python mysteriously disabled is a hassle to troubleshoot. NOTE: extern/audaspace/CMakeLists.txt has become out sync with the original [0], it seems this is being maintained in our repository. [0]: https://github.com/neXyon/audaspace/blob/master/CMakeLists.txt
2022-05-19Cleanup: format, reduce line length & strip trailing spaceCampbell Barton
2022-05-18Merge branch 'blender-v3.2-release'Campbell Barton
2022-05-18Fix T88792: WindowManager.clipboard missing in Python API docsCampbell Barton
Support RNA types using the Py/C-API PyGetSetDef defined properties. Currently `WindowManager.clipboard` is the only instance of this.
2022-05-18PyDoc: support building full API docs on macOS & WIN32Campbell Barton
Accessing context members depended on `ctypes` to access symbols which were hidden for macOS & WIN32. Add an API call that doesn't require the symbols to be exported. This allows most symbols to be hidden on Linux, see D14971.
2022-05-18Python: log the status of '--python-use-system-env' on initializationCampbell Barton
Report when the PYTHONPATH is expected to be used to help debug Python initialization issues (see T98131).
2022-05-17Cleanup: use term 'filepath' for full file pathsCampbell Barton
2022-05-13Cleanup: spelling in comments, capitalize tagsCampbell Barton
Also add missing task-ID reference & remove colon after \note as it doesn't render properly in doxygen.
2022-05-09Fix T97927: bpy.utils.units.to_string uses wrong units for velocity, ↵Bastien Montagne
acceleration, lens length, and power `TEMPERATURE` type was also missing, not only the new-ish `TIME_ABSOLUTE` one... Added a static assert on the size of the `bpyunits_ucategories_items` array, and a comment on anonymous enum of `B_UNIT_`, in the hope this won't happen again in the future.
2022-05-09Cleanup: typo in variable name.Bastien Montagne
2022-05-03Fix T97731: Python traceback no longer includes line-numbersCampbell Barton
Regression caused by [0] that caused the error message to be created based on a normalized exception (which hid line numbers). PyC_ExceptionBuffer{_Simple} & BPy_errors_to_report no longer clears the exception. This could have been resolved by changing python_script_error_jump however that would involve changes to reference counting that are more risky (noted in code-comment). [0]: 2d2baeaf04d481f284bc2f098fb6d7ee9268151f
2022-05-03Cleanup: remove redundant PyErr_Clear calls after PyErr_FetchCampbell Barton
2022-04-28Cleanup: unbalanced doxy sections, add some sectionsCampbell Barton
2022-04-26Fix memory leak in Context.temp_overrideCampbell Barton
Add missing check as the context override dict may have been copied since it was assigned, also initialize the context manager with PyType_Ready, while it didn't cause any errors - it's expected that all types are initialized.
2022-04-26Cleanup: use boolean arguments and return valuesCampbell Barton
2022-04-26PyAPI: support persistent handlers for class & static methodsCampbell Barton
Support methods being used as persistent callbacks. Resolves T97555.
2022-04-22Cleanup: spelling in commentsCampbell Barton
2022-04-20PyAPI: improve deprecation warning for bpy.ops context overrideCampbell Barton
- Increase the stack level so the reported line number references script authors code (not Blender's wrapper function). - Include the operator name and poll/call usage in the warning.
2022-04-20Fix crash passing no arguments to Context.temp_overrideCampbell Barton
2022-04-20PyAPI: temporary context override supportCampbell Barton
Support a way to temporarily override the context from Python. - Added method `Context.temp_override` context manager. - Special support for windowing variables "window", "area" and "region", other context members such as "active_object". - Nesting context overrides is supported. - Previous windowing members are restored when the context exists unless they have been removed. - Overriding context members by passing a dictionary into operators in `bpy.ops` has been deprecated and warns when used. This allows the window in a newly loaded file to be used, see: T92464 Reviewed by: mont29 Ref D13126
2022-04-20PyAPI: utility functions for parsing typed RNA argumentsCampbell Barton
These functions can be used with PyArg_ParseTupleAndKeywords (and related functions) to take typed RNA arguments without having to extract and type-check them separately. No functional changes, extracted from D13126.
2022-04-11Cleanup: malformed C-style comment blocks, spellingCampbell Barton
- Missing star prefix. - Unnecessary indentation. - Blank line after dot-points (otherwise doxygen merges with the previous dot-point). - Use back-slash for doxygen commands. - Correct spelling.