GPv3: Duplicate layer #117974
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#117974
Loading…
Reference in New Issue
No description provided.
Delete Branch "PratikPB2123/blender:gpv3-duplicate-layer"
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?
Port legacy layer duplicate operator
Thanks, added some comments.
@ -429,0 +440,4 @@
return OPERATOR_CANCELLED;
}
Layer *active_layer = grease_pencil.get_active_layer();
This can be a
Layer &
since you checked if there is an active layer before.@ -429,0 +445,4 @@
const Array<int> frame_numbers = active_layer->sorted_keys();
for (int frame : frame_numbers) {
grease_pencil.insert_blank_frame(new_layer, frame, 0, BEZT_KEYTYPE_KEYFRAME);
Instead of iterating over the keys here, iterate over
active_layer->frames()
like so:This means we can use the
frame.type
so we can pass it toinsert_blank_frame
.Also use
active_layer->get_frame_duration_at(key)
to get the duration.Thanks. Updated the PR
get_frame_duration_at
looks bit faulty. Calculating wrong duration value (causing assert hit)Can you paste the error you get? 🤔
Sure: Assert hit at
BLI_assert(duration >= 0);
inadd_frame()
I think frames returned by
frames()
are not sortedCall Stack
Test file: duplicate-layer.blend
Ah sorry, the correct way to do this is:
So
get_frame_duration_at
is correct indeed 🙂@ -429,0 +450,4 @@
if (!empty_keyframes) {
for (const int frame_number : frame_numbers) {
const Drawing *drawing = grease_pencil.get_drawing_at(*active_layer, frame_number);
This can be a
const Drawing &
Looks good now, thanks.
@blender-bot build
@ -429,0 +436,4 @@
const bool empty_keyframes = RNA_boolean_get(op->ptr, "empty_keyframes");
if (!grease_pencil.has_active_layer()) {
BKE_reportf(op->reports, RPT_ERROR, "No Active Layer to duplicate");
Active Layer
->active layer
Typically these sorts of things aren't capitalized in the UI
@ -429,0 +454,4 @@
for (const int frame_number : frame_numbers) {
const Drawing &drawing = *grease_pencil.get_drawing_at(active_layer, frame_number);
Drawing *new_drawing = grease_pencil.get_editable_drawing_at(new_layer, frame_number);
*new_drawing = *MEM_new<bke::greasepencil::Drawing>(__func__, drawing);
Maybe I'm missing something, this looks odd to me though. It looks like it's a memory leak, since it's allocating space for a drawing, but then just copying its contents into the memory pointed to by
new_drawing
.Does this work?
I've tried this. Got crash in constructor.
Dumb idea, I really didn't think about the memory leak, thanks 😅
Call stack
Also crashing sometimes in
grease_pencil_blend_write
With current PR, I tried
MEM_FreeN
to avoid memory leak, but leak is still occurring somehow 👀ok, so the crash in
grease_pencil_blend_write
was due to presence of vertex group.Without them, crash still occurs but this time drawing->runtime memory is freed right after assigning
bke::greasepencil::Drawing(drawing);
The destructor is called hence the memory is freed, then crash triggers due to accessing this freed memory in depsgraph evaluation.
Updated the PR to use
add_duplicate_drawings()
/add_empty_drawing()
instead :)Just to confirm @PratikPB2123, do you get crashes in
main
regarding the vertex groups?In main, no.
And now with this change, it's not crashing either with vgroups.
29fe777445
@blender-bot build