Rendering a scene with py-drivers would crash after dropping an
extension onto Blender's window then canceling before the update
completed.
This was caused by context.temp_override pushing arguments into the
context but failing to pop them in the case of an error - which would
happen when the popup was closed while the update ran.
ContextTempOverride objects were not freeing the reference to their
arguments when the context managers __exit__ didn't run.
This would happen if __enter__ failed with an unsupported configuration
or if object was created and not used.
Resolve by making ContextTempOverride a container type with GC support.
This also allows the ContextTempOverride to be reused since it's
arguments are now cleared when it's deallocated instead of __exit__.
Replace plain-text type information with the type syntax used
for Python's type annotations as it's more concise, especially for
callbacks which often didn't include useful type information.
Note that this change only applies to inline doc-strings,
generated doc-strings from RNA need to be updated separately.
Details:
- Many minor corrections were made when "list" was incorrectly used
instead of "sequence".
- Some type information wasn't defined in the doc-strings and has been
added.
- Verbose type info would benefit from support for type aliases.
This commit moves generated `RNA_blender.h`, `RNA_prototype.h` and
`RNA_blender_cpp.h` headers to become C++ header files.
It also removes the now useless `RNA_EXTERN_C` defines, and just
directly use the `extern` keyword. We do not need anymore `extern "C"`
declarations here.
Pull Request: https://projects.blender.org/blender/blender/pulls/124469
When restoring a temporary context, account for changes to the context
made by actions (typically operators) in the script.
There was an incorrect assumption that an override which didn't change
the current context would also be unchanged when restoring the temporary
context's original values.
Using screen changing functions with screens used for full screen areas
isn't supported & caused corrupt screen data.
Add checks that the current and overriding screen support switching,
raising an error when they don't. Also add a check when restoring the
context not to change any full screen areas.
When overriding the contexts window but not the screen, the context
override would attempt to use the current screen with the new window.
This raised an error and could crash when editing properties in the
key-map editor for the "context toggle" operator.
The recent addition screen override [0] failed to account for the
override windows screen being overridden when restoring the context.
When overriding the window and screen, it's incorrect to use the
original contexts screen when restoring the screen of the overriding
window.
This window's screen may not be in the original context or the
overriding screen. Resolve the bug by storing this separately
and use it when restoring the context.
[0]: 6af92e1360
Subtle regression in [0] caused context override to fail when
passing in the current context when a temporary screen was used.
While passing in a temporary screen as an override isn't supported,
this shouldn't raise an exception if the argument matches the current
context.
Also added sanity check that the window passed in exists
and code comments to give an explanation of the current behavior.
[0]: 6af92e1360
Previously it was checking the actually active screen - it was leading
to the issue where it's no longer possible to override context.screen
(#108763) which was possible with old context override method.
Now the screen can be overridden, keeping the window & workspace
consistent.
Ref !114269.
Co-authored-by: Andrej730 <azhilenkov@gmail.com>
- Account for new member in _PyArg_Parser.
- Many Python op-codes have been removed.
For the moment these are disabled in is_opcode_secure.
Some should be added back as intrinsics, noted in code-comments.
Listing the "Blender Foundation" as copyright holder implied the Blender
Foundation holds copyright to files which may include work from many
developers.
While keeping copyright on headers makes sense for isolated libraries,
Blender's own code may be refactored or moved between files in a way
that makes the per file copyright holders less meaningful.
Copyright references to the "Blender Foundation" have been replaced with
"Blender Authors", with the exception of `./extern/` since these this
contains libraries which are more isolated, any changed to license
headers there can be handled on a case-by-case basis.
Some directories in `./intern/` have also been excluded:
- `./intern/cycles/` it's own `AUTHORS` file is planned.
- `./intern/opensubdiv/`.
An "AUTHORS" file has been added, using the chromium projects authors
file as a template.
Design task: #110784
Ref !110783.
A context area/region override would be left cleared when the context
manager exited - if the overriding value matched the current value.
- `self->ctx_init.*_is_set` members would be set even if the those
arguments weren't passed in, because the values would compare
as different to NULL (unset).
- When restoring the context, setting a window clears the area & region,
setting the area clears the region.
This wasn't taken into account - only the members that were
overridden were restored.
In the case of #110632, the window & region were detected as changed,
even though neither were overridden.
So the window & region were restored. The area however was set to it's
self and not marked as changed, so the area was left cleared from the
call that restored the window.
Resolve by fixing the check for overridden members & restoring
context members that will have been cleared indirectly.
While these warnings point to real errors in the code,
PyMethodDef are an exception where functions with different numbers
of arguments are all cast to the same function type.