Collection Export: Allow renaming of exporters in the UI list #125553

Merged
Jesse Yurkovich merged 6 commits from deadpin/blender:collexport-renaming into main 2024-08-02 22:36:58 +02:00

Allow the user to rename their collection exporters.

Allow the user to rename their collection exporters.
Jesse Yurkovich force-pushed collexport-renaming from 8709203920 to cd5aea6191 2024-07-30 02:36:41 +02:00 Compare
Jesse Yurkovich requested review from Bastien Montagne 2024-07-30 19:13:39 +02:00
Bastien Montagne requested changes 2024-07-31 09:53:51 +02:00
Bastien Montagne left a comment
Owner

I would rather move the logic in rna_CollectionExport_friendly_name into the CollectionExporter code (aka collection_exporter_add_exec). that way, the name is defined as part of creation process, instead of using some random accessor code. ;)

Then you can probably get rid of all RNA callbacks for this property, since it becomes just a standard DNA-defined fixed-size char buffer.

There is also the question of whether this name should be unique or not? I would say yes, since that allows to reference the collection exporters data by their name. Just like we do e.g. with constraints or modifiers (and of course IDs themselves).


The following may be going out of scope for this PR, and could be addressed separately. But I think it would be good to also move the core creation code of CollectionExporter into BKE code (there is already a BKE_collection_exporter_free_data there). That way, other areas of code can easily create this data (thinking mainly about a RNA API to create and remove these exporters).

I would rather move the logic in `rna_CollectionExport_friendly_name` into the CollectionExporter code (aka `collection_exporter_add_exec`). that way, the name is defined as part of creation process, instead of using some random accessor code. ;) Then you can probably get rid of all RNA callbacks for this property, since it becomes just a standard DNA-defined fixed-size char buffer. There is also the question of whether this name should be unique or not? I would say yes, since that allows to reference the collection exporters data by their name. Just like we do e.g. with constraints or modifiers (and of course IDs themselves). ------------ The following may be going out of scope for this PR, and could be addressed separately. But I think it would be good to also move the core creation code of `CollectionExporter` into BKE code (there is already a `BKE_collection_exporter_free_data` there). That way, other areas of code can easily create this data (thinking mainly about a RNA API to create and remove these exporters).
Jesse Yurkovich added 2 commits 2024-07-31 19:03:05 +02:00
Author
Member

Fair feedback, thanks! I did leave the RNA setter because I need to prevent assignment of completely empty names as that seems like something reasonable to do. I'll keep the last part of the feedback in mind if/when more changes in the area occur.

Fair feedback, thanks! I did leave the RNA setter because I need to prevent assignment of completely empty names as that seems like something reasonable to do. I'll keep the last part of the feedback in mind if/when more changes in the area occur.
Bastien Montagne requested changes 2024-07-31 19:16:35 +02:00
Bastien Montagne left a comment
Owner

Would suggest adding a BKE_collection_exporter_name_set function, and call it from the everywhere (doversion, add operator, name set RNA callback)? Avoids duplicating the same logic everywhere, with the usual risk of getting it out of sync at some point in the future.

Would suggest adding a `BKE_collection_exporter_name_set` function, and call it from the everywhere (doversion, add operator, name set RNA callback)? Avoids duplicating the same logic everywhere, with the usual risk of getting it out of sync at some point in the future.
@ -4448,0 +4454,4 @@
LISTBASE_FOREACH (Collection *, collection, &bmain->collections) {
ListBase *exporters = &collection->exporters;
LISTBASE_FOREACH (CollectionExport *, data, exporters) {
if (data->name[0] == '\0') {

You need to call BLI_uniquename here too, even if the name is not empty

You need to call `BLI_uniquename` here too, even if the name is not empty
Author
Member

The lastest commit now calls BLI_uniquename as part of the processing but I think the check for data->name being empty is fine? This should only be the case during versioning unless I'm missing a scenario perhaps?

The lastest commit now calls `BLI_uniquename` as part of the processing but I think the check for data->name being empty is fine? This should only be the case during versioning unless I'm missing a scenario perhaps?

Hmmm in fact since you are bumping subversion number, I think you can drop the if block and replace it by an assert that the name is empty?

Hmmm in fact since you are bumping subversion number, I think you can drop the `if` block and replace it by an assert that the name _is_ empty?
deadpin marked this conversation as resolved
@ -475,1 +459,3 @@
return strlen(value);
/* Only set the name if it's not empty. */
if (value[0] != '\0') {
STRNCPY(data->name, value);

You need to call BLI_uniquename here as well.

You need to call `BLI_uniquename` here as well.
deadpin marked this conversation as resolved
Jesse Yurkovich added 1 commit 2024-07-31 20:31:24 +02:00
Bastien Montagne approved these changes 2024-08-02 11:09:31 +02:00
Bastien Montagne left a comment
Owner

LGTM now, added some notes below, don't think it needs further review once they are addressed.

LGTM now, added some notes below, don't think it needs further review once they are addressed.
@ -516,6 +517,18 @@ void BKE_collection_free_data(Collection *collection)
collection_free_data(&collection->id);
}
void BKE_collection_exporter_name_set(CollectionExport *data, const char *newname)

Doing a pointer look up in the listbase is not really expensive, especially when the list is expected to be small, but I would pass the owner listbase as a parameter here (handling cases where it's nullptr). Calling code knows it in two cases over three already, and hopefully once #122431 is finished the RNA code will have access to this info too.

Doing a pointer look up in the listbase is not really expensive, especially when the list is expected to be small, but I would pass the owner listbase as a parameter here (handling cases where it's `nullptr`). Calling code knows it in two cases over three already, and hopefully once #122431 is finished the RNA code will have access to this info too.
deadpin marked this conversation as resolved
Jesse Yurkovich added 2 commits 2024-08-02 21:53:29 +02:00
Feedback: use owning ListBase when available
All checks were successful
buildbot/vexp-code-patch-lint Build done.
buildbot/vexp-code-patch-linux-x86_64 Build done.
buildbot/vexp-code-patch-darwin-x86_64 Build done.
buildbot/vexp-code-patch-darwin-arm64 Build done.
buildbot/vexp-code-patch-windows-amd64 Build done.
buildbot/vexp-code-patch-coordinator Build done.
1e749db35b
Author
Member

@blender-bot build

@blender-bot build
Jesse Yurkovich merged commit 11e7b7d0bd into main 2024-08-02 22:36:58 +02:00
Jesse Yurkovich deleted branch collexport-renaming 2024-08-02 22:37:02 +02:00
Sign in to join this conversation.
No reviewers
No Label
Interest
Alembic
Interest
Animation & Rigging
Interest
Asset System
Interest
Audio
Interest
Automated Testing
Interest
Blender Asset Bundle
Interest
BlendFile
Interest
Collada
Interest
Compatibility
Interest
Compositing
Interest
Core
Interest
Cycles
Interest
Dependency Graph
Interest
Development Management
Interest
EEVEE
Interest
Freestyle
Interest
Geometry Nodes
Interest
Grease Pencil
Interest
ID Management
Interest
Images & Movies
Interest
Import Export
Interest
Line Art
Interest
Masking
Interest
Metal
Interest
Modeling
Interest
Modifiers
Interest
Motion Tracking
Interest
Nodes & Physics
Interest
OpenGL
Interest
Overlay
Interest
Overrides
Interest
Performance
Interest
Physics
Interest
Pipeline, Assets & IO
Interest
Platforms, Builds & Tests
Interest
Python API
Interest
Render & Cycles
Interest
Render Pipeline
Interest
Sculpt, Paint & Texture
Interest
Text Editor
Interest
Translations
Interest
Triaging
Interest
Undo
Interest
USD
Interest
User Interface
Interest
UV Editing
Interest
VFX & Video
Interest
Video Sequencer
Interest
Viewport & EEVEE
Interest
Virtual Reality
Interest
Vulkan
Interest
Wayland
Interest
Workbench
Interest: X11
Legacy
Asset Browser Project
Legacy
Blender 2.8 Project
Legacy
Milestone 1: Basic, Local Asset Browser
Legacy
OpenGL Error
Meta
Good First Issue
Meta
Papercut
Meta
Retrospective
Meta
Security
Module
Animation & Rigging
Module
Core
Module
Development Management
Module
Grease Pencil
Module
Modeling
Module
Nodes & Physics
Module
Pipeline, Assets & IO
Module
Platforms, Builds & Tests
Module
Python API
Module
Render & Cycles
Module
Sculpt, Paint & Texture
Module
Triaging
Module
User Interface
Module
VFX & Video
Module
Viewport & EEVEE
Platform
FreeBSD
Platform
Linux
Platform
macOS
Platform
Windows
Severity
High
Severity
Low
Severity
Normal
Severity
Unbreak Now!
Status
Archived
Status
Confirmed
Status
Duplicate
Status
Needs Info from Developers
Status
Needs Information from User
Status
Needs Triage
Status
Resolved
Type
Bug
Type
Design
Type
Known Issue
Type
Patch
Type
Report
Type
To Do
No Milestone
No project
No Assignees
2 Participants
Notifications
Due Date
The due date is invalid or out of range. Please use the format 'yyyy-mm-dd'.

No due date set.

Dependencies

No dependencies set.

Reference: blender/blender#125553
No description provided.