Fix #112068: Crash when loading converted curves #112280
No reviewers
Labels
No Label
Interest
Alembic
Interest
Animation & Rigging
Interest
Asset Browser
Interest
Asset Browser Project Overview
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
EEVEE & Viewport
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
Virtual Reality
Interest
Vulkan
Interest
Wayland
Interest
Workbench
Interest: X11
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
EEVEE & Viewport
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
Platform
FreeBSD
Platform
Linux
Platform
macOS
Platform
Windows
Priority
High
Priority
Low
Priority
Normal
Priority
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
3 Participants
Notifications
Due Date
No due date set.
Dependencies
No dependencies set.
Reference: blender/blender#112280
Loading…
Reference in New Issue
No description provided.
Delete Branch "filedescriptor/blender:fix-112068"
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
2788fa915b
theCurvesGeometry::blend_write
andCurvesGeometry::blend_read
functions were added. Unfortunately, the commit also altered the writing logic and introduced a bug where loading a file with a convertedCurves
object would crash. See #112068.This PR fixes the issue by making sure that
CustomData_blend_write_prepare
is called beforeBKE_id_blend_write
, which is the root cause of the crash that happens on load.The
CurvesGeometry::blend_write
function is split intoCurvesGeometry::blend_write_prepare
andCurvesGeometry::blend_write
.There should be a proper technical explanation about this change in the commit message (what was the issue with current code, why/how this commit fixes it). This is not exactly trivial, especially since current Curves data layout 'embeds' two other sub-layers of data (so writing the root ID struct also implicitly writes the
CurvesGeometry
data, which writes theCustomData
)...On a general level, I would also rather have a single
CurvesGeometryBlendWriteData blend_write_data
variable, generated by a newCurvesGeometry::blend_write_prepare()
method, and passed as single third extra argument toCurvesGeometry::blend_write()
(would also keep the ID as second argument here btw).That way, the logic is easier to extend in the future if needs be, and is not spread/duplicated in several parts of the code.
Generally LGTM now, would rather have actual C++ experts give it another pass though.
Left a couple of comments, but generally the structure of the new code looks good to me, so don't think another review would be necessary from me at this point.
@ -399,0 +409,4 @@
* This function needs to be called before `blend_write` and before the `CurvesGeometry` struct
* is written because it can mutate the `CustomData` struct.
*/
void blend_write_prepare(CurvesGeometryBlendWriteData &write_data);
Not a C++ expert, but can't this function simply return a
CurvesGeometryBlendWriteData
object? I would expect a copy elision to happen here (or at worse, a copy using the 'move' mechanism)?@ -399,0 +410,4 @@
* is written because it can mutate the `CustomData` struct.
*/
void blend_write_prepare(CurvesGeometryBlendWriteData &write_data);
void blend_write(BlendWriter &writer, const CurvesGeometryBlendWriteData &write_data ID &id);
missing coma?...
Also, please pass the ID argument first (just after the
writer
one), it remains the 'main' data to be written, additional data specific to a data types should be added after it.@ -54,0 +54,4 @@
/**
* Helper struct for `CurvesGeometry::blend_write_*` functions.
*/
struct CurvesGeometryBlendWriteData {
This struct could be defined as
BlendWriteData
just before theblend_write_prepare
function, insidebke::CurvesGeometry
@ -394,3 +394,3 @@
* File Read/Write.
*/
public:
Is public necessary here? Seems the stuff above is already public
@ -105,12 +105,16 @@ static void curves_blend_write(BlendWriter *writer, ID *id, const void *id_addre
{
Curves *curves = (Curves *)id;
/* Make sure to call `CurvesGeometry::blend_write_prepare()` before writing the struct. */
Think this comment is redundant with documentation in
blend_write_prepare
and the face thatblend_write
requires this as an argument. Same in the GP file@ -2054,3 +2055,4 @@
switch (drawing_base->type) {
case GP_DRAWING: {
GreasePencilDrawing *drawing = reinterpret_cast<GreasePencilDrawing *>(drawing_base);
blender::bke::CurvesGeometry::BlendWriteData write_data =
blender::
unnecessary here