I18n: add per-socket translation contexts for nodes #105195
No reviewers
Labels
No Label
Interest
Alembic
Interest
Animation & Rigging
Interest
Asset System
Interest
Audio
Interest
Automated Testing
Interest
Blender Asset Bundle
Interest
BlendFile
Interest
Code Documentation
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 & 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
Asset System
Module
Core
Module
Development Management
Module
Grease Pencil
Module
Modeling
Module
Nodes & Physics
Module
Pipeline & 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
5 Participants
Notifications
Due Date
No due date set.
Dependencies
No dependencies set.
Reference: blender/blender#105195
Loading…
Reference in New Issue
Block a user
No description provided.
Delete Branch "pioverfour/blender:dp_per_node_socket_translation_context"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
In order to properly translate UI messages, they sometimes need to be
disambiguated using translation contexts. Until now, node sockets had
no way to specify contexts and collisions occurred.
This commit adds a way to declare contexts for each socket using:
.translation_context()
If no context is specified, the default null context is used.
This is a new approach for D15869. Since then, node systems have been ported to the C++ node declaration system.
@ -184,0 +187,4 @@
const nodes::SocketDeclaration &socket_decl = *socket.runtime->declaration;
/* The node is not explicitly defined. */
if (&socket_decl == nullptr) {
This is needed to avoid a crash when certain nodes are added (for instance, Render Layers in the compositing nodes).
GCC gives a warning:
the compiler can assume that the address of ‘socket_decl’ will never be NULL [-Waddress]
.I suppose it means this should not happen because a null pointer would mean a bug occurs before reaching this point. But I don’t know how to fix this better since it appears not all nodes have a declaration.
You cannot use a reference if there is a chance that the pointer will be NULL. So if
socket.runtime->declaration
can benullptr
, you need to use a pointer forsocket_decl
- or do the check before assigning it to your reference.At first check
socket.runtime->declaration != nullptr
, and after that dereference pointerThanks for the help! I hope I fixed this correctly.
Bastien Montagne referenced this pull request2023-02-26 16:39:20 +01:00
@blender-bot build
Generally LGTM, though there are a few points to be addressed as noted below.
Would also summon @JacquesLucke here. ;)
@ -184,0 +198,4 @@
}
output << translation_context.data();
return BLI_strdup(output.str().c_str());
Not sure why you are using an intermediate
std::stringstream
here? Can't you just doreturn BLI_strdup(socket_decl.translation_context.c_str());
?That sounds reasonable.
I guess the reason for why the
std::stringstream
was used is that you assigned it to aStringRef
which does not havec_str
method, because it might not be null-terminated. Usingconst StringRefNull
or what @mont29 would be better though.To be quite honest I copied code doing a similar thing from
node_socket_get_tooltip()
, but I see that it doesn’t really apply here.I’ll go with @mont29 ’s solution.
Besides what was mentioned in the code comments, this looks good to me.
04b5877712
to8e79420a20
@JacquesLucke @mont29 Do you reckon this can go into 3.5?
Noticed one issue, big picture seems good.
@ -184,0 +195,4 @@
return nullptr;
}
return BLI_strdup(translation_context.data());
Why
BLI_strdup
? Could you just useStringRefNull
and return that directly? It looks like the result isn't being freed, and this negates the benefit of any small string optimization instd::string
Besides point raised by @HooglyBoogly, LGTM. But don't think this should go in 3.5, it's not that trivial of a change...
Damien Picard referenced this pull request2023-03-12 16:27:05 +01:00