Fix #123220: Export GP SVG/PDF crash when active object is not GP #123224

Merged
Philipp Oeser merged 2 commits from lichtwerk/blender:123220 into blender-v4.2-release 2024-06-18 16:44:22 +02:00
Member

GpencilIOParams.ob is set to CTX_data_active_object at the beginning
of the export [which is not ensured to be a valid OB_GPENCIL_LEGACY
object, non-valid objects are filtered out later in
create_object_list]. From this (potential non-greasepencil) object's
data, a "global bGPdata is stored in GpencilIOParams.

From here, it can only go downwards as stroke_point_radius_get,
export_stroke_to_polyline, BKE_gpencil_stroke_perimeter_from_view
all use this "global" bGPdata.

Two possible solutions might exist:

  • [1] just cancel the operator if the active object is not a
    OB_GPENCIL_LEGACY object
  • [2] make sure we use corresponding bGPdata when iterating over
    valid objects to export

This PR chooses [2] since it also seems wrong to always use the
bGPdata from the active object for certain calculations when iterating
many objects. For example, the export ignores different values for
Thickness Scale on different objects and always takes the value from
the active object, which does not seem to be by design.

NOTE: this changes behavior (see above) but for the better

`GpencilIOParams.ob` is set to `CTX_data_active_object` at the beginning of the export [which is not ensured to be a valid `OB_GPENCIL_LEGACY` object, non-valid objects are filtered out later in `create_object_list`]. From this (potential non-greasepencil) object's data, a "global `bGPdata` is stored in `GpencilIOParams`. From here, it can only go downwards as `stroke_point_radius_get`, `export_stroke_to_polyline`, `BKE_gpencil_stroke_perimeter_from_view` all use this "global" `bGPdata`. Two possible solutions might exist: - [1] just cancel the operator if the active object is not a `OB_GPENCIL_LEGACY` object - [2] make sure we use corresponding `bGPdata` when iterating over valid objects to export This PR chooses [2] since it also seems wrong to always use the `bGPdata` from the active object for certain calculations when iterating many objects. For example, the export ignores different values for `Thickness Scale` on different objects and always takes the value from the active object, which does not seem to be by design. NOTE: this changes behavior (see above) but for the better
Philipp Oeser added this to the Grease Pencil project 2024-06-14 11:58:26 +02:00
Philipp Oeser added the
Interest
Import Export
Interest
Pipeline, Assets & IO
labels 2024-06-14 11:58:42 +02:00
Philipp Oeser requested review from Falk David 2024-06-14 11:58:51 +02:00
Philipp Oeser requested review from YimingWu 2024-06-14 11:58:58 +02:00
Member

For example, the export ignores different values for
Thickness Scale on different objects and always takes the value from
the active object, which does not seem to be by design?

This doesn't seem that optimal tbh 🤔 But since the operator is working with active object anyway, it shouldn't really affect much?

> For example, the export ignores different values for > Thickness Scale on different objects and always takes the value from > the active object, which does not seem to be by design? This doesn't seem that optimal tbh 🤔 But since the operator is working with active object anyway, it shouldn't really affect much?
Author
Member

For example, the export ignores different values for
Thickness Scale on different objects and always takes the value from
the active object, which does not seem to be by design?

This doesn't seem that optimal tbh 🤔 But since the operator is working with active object anyway, it shouldn't really affect much?

I dont quite get this comment.
Current situation:

  • export is working with active object (ignoring different values) >> not optimal

Proposed situation (as in this PR):

  • export would work with iterated object data (taking into account different values) >> this affects behavior but is much more expected?
> > For example, the export ignores different values for > > Thickness Scale on different objects and always takes the value from > > the active object, which does not seem to be by design? > > This doesn't seem that optimal tbh 🤔 But since the operator is working with active object anyway, it shouldn't really affect much? I dont quite get this comment. Current situation: - export is working with active object (ignoring different values) >> not optimal Proposed situation (as in this PR): - export would work with iterated object data (taking into account different values) >> this affects behavior but is much more expected?
Member

export would work with iterated object data (taking into account different values) >> this affects behavior but is much more expected?

Ah I understood now. Then it's better :D

> export would work with iterated object data (taking into account different values) >> this affects behavior but is much more expected? Ah I understood now. Then it's better :D
Falk David requested changes 2024-06-17 11:15:05 +02:00
Dismissed
Falk David left a comment
Member

It looks like gpd_ is only used in a single place in that function (blender/source/blender/io/gpencil/intern/gpencil_io_export_pdf.cc:205) where we probably should use gpd_eval anyway. I have the feeling that gpd_ is not needed and should be removed instead.

It looks like `gpd_` is only used in a single place in that function (`blender/source/blender/io/gpencil/intern/gpencil_io_export_pdf.cc:205`) where we probably should use `gpd_eval` anyway. I have the feeling that `gpd_` is not needed and should be removed instead.
Author
Member

gpd_ is used in

  • stroke_point_radius_get
    -- which is used by GpencilExporterPDF::export_stroke_to_polyline
    -- which is used by GpencilExporterSVG::export_stroke_to_polyline
  • GpencilExporterPDF::export_gpencil_layers call to BKE_gpencil_stroke_perimeter_from_view
  • GpencilExporterSVG::export_gpencil_layers call to BKE_gpencil_stroke_perimeter_from_view

Using gpd_eval and passing that around seems fine, will do.

gpd_ is also used in the importer (that area I wouldnt touch though)

`gpd_` is used in - `stroke_point_radius_get` -- which is used by `GpencilExporterPDF::export_stroke_to_polyline` -- which is used by `GpencilExporterSVG::export_stroke_to_polyline` - `GpencilExporterPDF::export_gpencil_layers` call to `BKE_gpencil_stroke_perimeter_from_view` - `GpencilExporterSVG::export_gpencil_layers` call to `BKE_gpencil_stroke_perimeter_from_view` Using `gpd_eval` and passing that around seems fine, will do. `gpd_` is also used in the importer (that area I wouldnt touch though)
Philipp Oeser force-pushed 123220 from 47d43005ea to 75fd326ab7 2024-06-17 14:54:25 +02:00 Compare
Philipp Oeser requested review from Falk David 2024-06-17 14:55:14 +02:00
Falk David approved these changes 2024-06-17 15:20:46 +02:00
Falk David left a comment
Member

Looks good to me :)

Looks good to me :)
Author
Member

@blender-bot build

@blender-bot build
Philipp Oeser merged commit 751745b2de into blender-v4.2-release 2024-06-18 16:44:22 +02:00
Philipp Oeser deleted branch 123220 2024-06-18 16:44:29 +02:00
Author
Member

@filedescriptor / @ChengduLittleA : double-checking if you would want this fix in LTS? (my vote would probably be against it since it changes behavior -- even if for the better...)

@filedescriptor / @ChengduLittleA : double-checking if you would want this fix in LTS? (my vote would probably be against it since it changes behavior -- even if for the better...)
Member

I think it would be fine to fix this in LTS actually. But you're right, it's a bit of a grey area.

I think it would be fine to fix this in LTS actually. But you're right, it's a bit of a grey area.
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
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
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
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
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#123224
No description provided.