Commit Graph

2827 Commits

Author SHA1 Message Date
Philipp Oeser
fcc481a407 Render: include info string for "render_stats" handler
The "render_stats" handler now includes the message line that was
written to stdout as the first arg (using `BKE_callback_exec_string`
instead of just `BKE_callback_exec_null`).

This can be useful to track render progress (and people were relying on
parsing stdout in the past).

Was a request in chat.

This also corrects possible output from the callback being written in
between message parts in `do_write_image_or_movie` (which was probably a
mistake in 93d5e106aa).

Pull Request: https://projects.blender.org/blender/blender/pulls/119789
2024-05-28 17:07:27 +02:00
Julian Eisel
2fbf206491 UI: Allow passing named strings via context
Sometimes it is necessary to pass additional data through generic UI entities,
to specific implementations. For example to pass additional options to panel
polling & drawing when instantiating a panel through its panel type. Or storing
additional data in a button, without hardcoding it in the button struct/class.

Passing data via context is a simple solution to this, however so far this only
works using hardcoded context queries or RNA pointers. For passing arbitrary
strings we've used workarounds like creating an RNA type to wrap it already.
For example `RNA_AssetCatalogPath`, which is used to dynamically populate menu
items based on an asset catalog path, via a generic menu type.
type instantiation. This makes it possible to invoke specific asset shelves as
popover panels.

Idea is simply to let `bContextStore` entries hold copies of the string (as
`std::string`), avoiding lifetime issues. Context APIs are extended to support
setting/querying strings via a context member name.

Pull Request: https://projects.blender.org/blender/blender/pulls/122113
2024-05-27 18:46:19 +02:00
Campbell Barton
4f73df2b7b Extensions: enable extensions.blender.org, adjust welcome screen
Splash screen notification text:

- When starting in "Offline mode" with repositories with installed
  packages enabled, the text is clickable unless launched with
  `--offline-mode`, the tooltip notes that the command line setting
  can't be changed at run-time.
- Don's show anything if there are not extensions installed.

Preferences:

- Don't show the welcome message on preferences if:
  - Blender is online.
  - The message was dismissed.
  - There are no enabled remote repositories.

- The option to enable extensions.blender.org has been replaced with
  a button that switches to the "System" tab where Online Access
  can be enabled.

Also expose bpy.app.online_access_override needed for the UI to check
if online access was disabled using command line arguments.
2024-05-24 16:51:36 +10:00
Campbell Barton
57c023d580 Preference: add option allow internet access
Add a preference to "Work Offline" system preference as well as command
line options `--offline-mode` & `--online-mode`
(which overrides the preference).
This option is displayed in the initial setup screen too.

This is currently respected by:

- Check for updates on startup
- Disables running an update when enabling extensions.

When Blender is launched with `--offline-mode` the option cannot be
enabled in the preferences. This is intended for environments
where internet access is intentionally disallowed.

Background: with Blender supporting access to online-repositories
as well as 3rd party extensions themselves potentially accessing the
internet. This setting provides a way for users to disable online
functionality.

This prevents error messages when online access fails in environments
without internet access as well as the ability for users who prefer
Blender doesn't access the internet to have one place to turn this off.

While it does not enforce limitations on add-ons, 3rd party scripts
are expected to respect this setting using `bpy.app.internet_offline`.

The details for this will be handled along with other policies scripts
are expected to follow.

Ref !121994
2024-05-23 13:50:06 +10:00
Iliya Katueshenock
75d17b1db5 Cleanup: Move BKE_node to namespace
Move all header file into namespace.
Unnecessary namespaces was removed from implementations file.
Part of forward declarations in header was moved in the top part
of file just to do not have a lot of separate namespaces.

Pull Request: https://projects.blender.org/blender/blender/pulls/121637
2024-05-13 16:07:12 +02:00
Bastien Montagne
a6153bb7d5 Fix (unreported) crash when linking data from other endianness files.
Handling of the blendfile handle freeing when linking data from a
blendfile requiring endianness conversion was totally broken, leading
to double-freeing attempts.

Guess that the fact that this was never reported shows how rare
'big-endian' blendfiles are nowadays... But we still have a few in our
test repo.
2024-05-10 16:00:30 +02:00
Sybren A. Stüvel
45bf2eae98 Refactor: Anim: simplify ANIM_remove_driver()
Simplify `ANIM_remove_driver()` by removing unused parameters and handling
simple cases first.

No functional changes.

Pull Request: https://projects.blender.org/blender/blender/pulls/121655
2024-05-10 15:43:31 +02:00
Ahmed Essam
0ca1386426 Fix assert in debug mode when built as Python module
Ref: !121500
2024-05-09 09:51:11 +10:00
Campbell Barton
41efa30a75 Fix failure to catch errors parsing arguments to Context.temp_override
Resolve unhandled exception when invalid types for StructRNA arguments
were passed to temp_override(..).
2024-05-08 23:37:22 +10:00
Campbell Barton
c34a1b5c47 Cleanup: use return instead of an argument for PyC_MainModule_Backup 2024-05-04 16:42:08 +10:00
Campbell Barton
cd5dd6e454 Fix #115648: Crash on startup with an incompatible PYTHONPATH
Regression in [0]. PyPreConfig.use_environment was internalized to 0
but PyConfig.use_environment wasn't.

Thanks to @unwave for finding the root cause.

[0]: cafd6b519c
2024-05-03 15:48:35 +10:00
Jacques Lucke
71ba360ddc Cleanup: use Map for operator types
This simplifies the code, makes it more type safe and also makes it
easier to use the construct-on-first-use-idiom.

Pull Request: https://projects.blender.org/blender/blender/pulls/121170
2024-04-27 21:44:55 +02:00
Campbell Barton
95315e34bf PyAPI: add private API to access WM capabilities
Add _bpy._wm_capabilities(), needed for preferences code to check if
WM functionality is supported. This could be made into a public
function, see code comments for details.
2024-04-26 21:26:49 +10:00
Campbell Barton
91cf938e40 Fix #120859: Script errors longer jump to the line in the text-editor
Since upgrading to Python 3.11, errors (other than syntax errors)
no longer jumped to the location of the error as they used to.

This was caused by the line number being unset, relying on the
attribute access to return the actual value.

Resolve by using attribute access when the struct member can't be used.
2024-04-23 18:18:49 +10:00
Christoph Lendenfeld
c30647a6fc Refactor: remove ReportList argument from insert_key
The insert key function in `animrig/keyframing.cc` took a `ReportList`
argument which it used to print messages in case of failures.

Instead this now returns a `CombinedKeyingResult` and the caller is
responsible for creating reports out of that.

To make that simpler the `ID` argument has been changed from a pointer to a reference.
The calling functions now make sure that it's not a `nullptr`.

This has the effect that there will be less messages printed in the Info panel when e.g. inserting keys with a keyingset.
This still doesn't make an error message pop up though.

Related to #119776

Pull Request: https://projects.blender.org/blender/blender/pulls/120784
2024-04-23 10:10:23 +02:00
Lukas Stockner
cc541f2c07 UI: Add Wavelength unit for scene-independent nanometer-scale inputs
Currently this is only used for the Wavelength node, but it will also be relevant for the Thin Film Interference support in the Principled BSDF.

Pull Request: https://projects.blender.org/blender/blender/pulls/120900
2024-04-22 13:10:16 +02:00
Campbell Barton
0ceefd6358 Cleanup: cmake syntax 2024-04-19 15:50:26 +10:00
Campbell Barton
c0e4de8457 PyAPI: support evaluating an expression as a string or None
Utility functions will be used as part of !120283.
2024-04-18 10:35:51 +10:00
Campbell Barton
cf37424203 Cleanup: use const pointers, quiet cppcheck unreadVariable warning 2024-04-17 11:36:38 +10:00
Campbell Barton
904d51d6cb RNA: use boolean for function callbacks & "valid" iterator state
Integers were used when the value is logically a boolean.

Ref !120130
2024-04-15 23:04:38 +10:00
Sybren A. Stüvel
1315991ecb Anim: add keytype argument to keyframe_insert() RNA function
Add an optional keyword argument `keytype` to the
`rna_struct.keyframe_insert()` function.

This makes it possible to set the new key's type. The code for this was
almost all in place, the only thing that was missing was the RNA
wrapper, which is what this commit adds.

Example: `bpy.context.object.keyframe_insert("location",
keytype='JITTER')`

There is no backward compatibility issue here, because the argument is
optional and defaults to the previously hardcoded value of `KEYFRAME`.

Pull Request: https://projects.blender.org/blender/blender/pulls/120578
2024-04-15 11:36:38 +02:00
Hans Goudey
c91449836a Cleanup: Move BKE_workspace.h to C++ 2024-04-12 17:03:18 -04:00
Campbell Barton
6776d68f5e Cleanup: avoid shadowing variables 2024-04-09 14:07:17 +10:00
Campbell Barton
bce2cf5f92 Cleanup: use const EnumPropertyItem pointers 2024-04-08 12:03:03 +10:00
Campbell Barton
c9130ad460 Python: support a null context for BPY_run_string_{exec/eval}
This was only used for accessing the CTX_wm_reports and isn't needed
for running scripts.
2024-04-05 12:33:48 +11:00
Campbell Barton
06dcd264ea Python: assert Python start/end/reset are used properly 2024-04-05 11:41:12 +11:00
Campbell Barton
d514b3b53b Cleanup: use explicit casts when assigning booleans to floats
While valid, this isn't so common and cppcheck warns about this,
use explicit casts to suppress the warning, also correct "true"
being assigned to a float value.
2024-04-01 22:20:09 +11:00
Campbell Barton
7e5a712e58 Cleanup: remove redundant null pointer checks
Based on the surrounding context these checks aren't needed.
2024-04-01 22:20:09 +11:00
Campbell Barton
0ef033750f Cleanup: pass arguments by const reference 2024-03-28 17:16:33 +11:00
Campbell Barton
872c997c8f Cleanup: remove redundant break & return statements 2024-03-28 13:01:37 +11:00
Campbell Barton
481bcc14d7 Cleanup: quiet enum conversion warning 2024-03-28 13:01:31 +11:00
Hans Goudey
acd1b0b7f9 Refactor: Use C++ Vector for RNA/context collection retrieval
Previously retrieving a collection from the context like "selected_ids"
would give a linked list of allocated items. Now it returns a vector of
RNA pointers. Though the number of items is typically fairly small,
using contiguous memory and avoiding many small allocations are
typical performance improvements that could still be beneficial
when there are many items. Iteration also becomes much simpler.

Pull Request: https://projects.blender.org/blender/blender/pulls/119939
2024-03-27 00:47:39 +01:00
Campbell Barton
40ab214c0a Cleanup: spelling in comments 2024-03-27 10:25:31 +11:00
Hans Goudey
efee753e8f Cleanup: Move BKE_idprop.h to C++ 2024-03-26 13:07:04 -04:00
Hans Goudey
1dc16f909d Cleanup: Move GPU Python headers to C++ 2024-03-23 10:06:45 -04:00
Hans Goudey
8b514bccd1 Cleanup: Move remaining GPU headers to C++
Pull Request: https://projects.blender.org/blender/blender/pulls/119807
2024-03-23 01:24:18 +01:00
Christoph Lendenfeld
646f9bcebe Refactor: Remove bAction argument from insert_keyframe
No functional changes intended.

The `insert_keyframe` function had a `bAction` argument that could be
a `nullptr`. If it was a `nullptr` it would be queried from the `ID`.

However in all cases where it is passed it is also gotten from the `ID`, making
the argument redundant.

This PR removes the argument to simplify the function.

Pull Request: https://projects.blender.org/blender/blender/pulls/119742
2024-03-22 13:18:32 +01:00
Campbell Barton
44defbd2c7 Extensions: add BLENDER_USER_EXTENSIONS user directory
Replace: `{BLENDER_RESOURCE_PATH_USER}/extensions`
With:    `{BLENDER_USER_EXTENSIONS}`

This follows BLENDER_USER_CONFIG & BLENDER_USER_SCRIPTS conventions.
Reading the environment variable and accessible via
`bpy.utils.user_resource('SCRIPTS')`
2024-03-22 16:08:25 +11:00
Campbell Barton
6bfc8612bf Cleanup: remove BLENDER_USER_AUTOSAVE
This was only used on WIN32 when the temporary directory didn't exist.
When the check was added [0] this made some sense because it relied on
`U.tempdir` existing, since then additional checks have been added to
ensure a temporary directory can be used. Further, this fall-back
location isn't documented in the user manual.

[0]: 615db01b01
2024-03-22 16:08:25 +11:00
Campbell Barton
f64f3e8524 Extensions: recursively remove custom-directories on repo removal
Even though there is a dialog users must accept when removing a
repository & directory being removed is shown, it's possible users
assume this only removes files which are part of the repository after
pointing the custom-directory to their home directory or similar.

Removing repositories which point to a custom-directory now only
remove packages and server meta-data to prevent accidents.

Resolves #119481.
2024-03-21 11:43:00 +11:00
Pratik Borhade
1ef6d1a11b Merge branch 'blender-v4.1-release' 2024-03-19 14:58:56 +05:30
Sybren A. Stüvel
30711d1398 Fix #119623: Anim: unintended API change in keyframe_insert() function
Bring back the `INSERTKEY_XYZ_TO_RGB` enum item for the
`keyframe_insert()` function (it was removed in 30b0c5b225). This way
any Python code that targets Blender 4.x can safely pass this flag,
without having to check specific Blender versions.

Note that the flag is implemented as a no-op, as the behaviour change
introduced in 30b0c5b225 (just looking at the user preference) is still
retained. The purpose of this commit is simply to avoid the `ValueError`
exception that would otherwise be raised.

This should also fix Rigify report blender/blender-addons#105241.

Pull Request: https://projects.blender.org/blender/blender/pulls/119625
2024-03-19 10:05:22 +01:00
Campbell Barton
a535524fe1 Fix #119500: Installing an Extension via dragging has no feedback
Call the install operators directly instead of using bpy.app.handlers.
Now reports from installing are in the status bar.
2024-03-19 18:12:10 +11:00
Campbell Barton
38dc888d7f Cleanup: use ELEM macro, remove redundant "struct" 2024-03-19 14:17:47 +11:00
Brecht Van Lommel
7a395e2e7f Revert changes from main commits that were merged into blender-v4.1-release
The last good commit was f57e4c5b98.

After this one more fix was committed, this one is preserved as well:
67bd678887.
2024-03-18 15:04:12 +01:00
Campbell Barton
0b9ef9ee2a Fix missing newline from bpy.utils.register_cli_command doc-string 2024-03-15 13:45:06 +11:00
Campbell Barton
499a2b2b4b Cleanup: remove double-space in exception message 2024-03-13 17:12:51 +11:00
Campbell Barton
5fd64db1cf Merge branch 'blender-v4.1-release' 2024-03-12 16:39:59 +11:00
Campbell Barton
59cba89f1b Merge branch 'blender-v4.1-release' 2024-03-12 16:39:56 +11:00
Campbell Barton
1fa2a1a74d Fix error freeing bpy_struct sub-classes WITH_PYTHON_SECURITY enabled
Python's behavior changed since this feature was added causing the
object to be tracked when freed by Python's subtype_dealloc even
if Blender has not tracked the data. Detect this case and untrack
the object before freeing.
2024-03-12 16:37:36 +11:00