Fix #112683: Removing the last Annotations layer produces a warning. #113274

Merged
Pratik Borhade merged 3 commits from MilanDavidovic/blender:fix-gpencil-remove-last-layer into blender-v4.0-release 2023-10-22 07:39:41 +02:00
Contributor

After removing the last Annotations layer, the current GPencil block
needs to be freed.

After removing the last Annotations layer, the current GPencil block needs to be freed.
Pratik Borhade requested changes 2023-10-05 13:19:40 +02:00
Pratik Borhade left a comment
Member

Hi, thanks for the PR. Bug remains when annotation channel is deleted from animation editors.
You can do similar change in BKE_gpencil_layer_delete when annoation data is deleted: gpd->flag & GP_DATA_ANNOTATIONS

cc @antoniov

Hi, thanks for the PR. Bug remains when annotation channel is deleted from animation editors. You can do similar change in `BKE_gpencil_layer_delete` when annoation data is deleted: `gpd->flag & GP_DATA_ANNOTATIONS` cc @antoniov
Author
Contributor

Hi, thanks for the PR. Bug remains when annotation channel is deleted from animation editors.
You can do similar change in BKE_gpencil_layer_delete when annoation data is deleted: gpd->flag & GP_DATA_ANNOTATIONS

cc @antoniov

Hi Pratik, thanks for noting that. I'll make the change.

> Hi, thanks for the PR. Bug remains when annotation channel is deleted from animation editors. > You can do similar change in `BKE_gpencil_layer_delete` when annoation data is deleted: `gpd->flag & GP_DATA_ANNOTATIONS` > > cc @antoniov Hi Pratik, thanks for noting that. I'll make the change.
Author
Contributor

BKE_gpencil_layer_delete is called from gpencil_layer_remove_exec, where I've made the change. It seems to me that moving the change to BKE_gpencil_layer_delete (i.e. deleting gpd there) wouldn't make sense, since it deals with deleting layers only.

It might be better to do the similar change in animchannels_delete_exec for animation channel type ANIMTYPE_GPLAYER. What do you think @PratikPB2123 ?

`BKE_gpencil_layer_delete` is called from `gpencil_layer_remove_exec`, where I've made the change. It seems to me that moving the change to `BKE_gpencil_layer_delete` (i.e. deleting gpd there) wouldn't make sense, since it deals with deleting layers only. It might be better to do the similar change in `animchannels_delete_exec` for animation channel type `ANIMTYPE_GPLAYER`. What do you think @PratikPB2123 ?
Member

I see, BKE_gpencil_layer_delete is called from both the operations. In that case, it make sense to move your fix in BKE_gpencil_layer_delete function, this will avoid code duplication too. And this function seems correct place to deal with layers.
I think original code was written by @antoniov so his opinion will be more valuable.

I see, `BKE_gpencil_layer_delete` is called from both the operations. In that case, it make sense to move your fix in `BKE_gpencil_layer_delete` function, this will avoid code duplication too. And this function seems correct place to deal with layers. I think original code was written by @antoniov so his opinion will be more valuable.
Pratik Borhade requested review from Antonio Vazquez 2023-10-09 12:06:09 +02:00
Author
Contributor

Avoiding code duplication sounds good. BKE_gpencil_layer_delete would then have to take bGPdata **gpd though, so that it can null the correct pointer (&scene->gpd in animchannels_delete_exec and the one returned by ED_annotation_data_get_pointers in gpencil_layer_remove_exec).

Avoiding code duplication sounds good. `BKE_gpencil_layer_delete` would then have to take `bGPdata **gpd` though, so that it can null the correct pointer (`&scene->gpd` in `animchannels_delete_exec` and the one returned by `ED_annotation_data_get_pointers` in `gpencil_layer_remove_exec`).
Member

We also need context for ED_annotation_data_get_pointers So I think it make sense to not move your code in BKE_gpencil_layer_delete

Best to do it separately in gpencil_layer_remove_exec , animchannels_delete_exec (as you said earlier) 🙂

We also need context for `ED_annotation_data_get_pointers` So I think it make sense to not move your code in `BKE_gpencil_layer_delete` Best to do it separately in `gpencil_layer_remove_exec` , `animchannels_delete_exec` (as you said earlier) 🙂
Pratik Borhade requested changes 2023-10-11 11:55:41 +02:00
@ -2241,2 +2241,4 @@
BKE_gpencil_layer_delete(gpd, gpl);
ale->update = ANIM_UPDATE_DEPS;
/* If we removed the last layer for annotations, free the scene's GPencil block. */
Member

Thanks. I think comment can be improved. For example:
/* Free Grease Pencil data block when last annotation layer is removed, see: #112683. */

Thanks. I think comment can be improved. For example: `/* Free Grease Pencil data block when last annotation layer is removed, see: #112683. */`
Author
Contributor

Thanks Pratik, I'll make the change. Should I also change the comment in the other file?

Thanks Pratik, I'll make the change. Should I also change the comment in the other file?
Member

yes, both :)

yes, both :)
MilanDavidovic marked this conversation as resolved
Milan Davidović requested review from Pratik Borhade 2023-10-12 09:11:30 +02:00
Pratik Borhade approved these changes 2023-10-20 13:28:42 +02:00
Pratik Borhade left a comment
Member

Thanks. Looks correct now. Would be good to have this in 4.0
Could you rebase the PR from main branch to 4.0: refer Rebase Onto

Thanks. Looks correct now. Would be good to have this in 4.0 Could you rebase the PR from main branch to 4.0: [refer Rebase Onto](https://wiki.blender.org/wiki/Tools/Pull_Requests#:~:text=Rebasing%20a%20Pull%20Request)
Milan Davidović changed title from Fix #112683: Removing the last Annotations layer produces a warning. to Fix #112683: Removing the last Annotations layer produces a warning. 2023-10-20 20:27:07 +02:00
MilanDavidovic changed target branch from main to blender-v4.0-release 2023-10-20 20:27:12 +02:00
Milan Davidović force-pushed fix-gpencil-remove-last-layer from fc2375d8f6 to 989113c5b6 2023-10-20 20:28:15 +02:00 Compare
Pratik Borhade approved these changes 2023-10-21 07:10:17 +02:00
Pratik Borhade left a comment
Member

Thanks :)

Thanks :)
Member

@antoniov , can you give final look before merging?

@antoniov , can you give final look before merging?
Antonio Vazquez approved these changes 2023-10-21 10:38:17 +02:00
Pratik Borhade merged commit 19b112b11c into blender-v4.0-release 2023-10-22 07:39:41 +02:00
Sign in to join this conversation.
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
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#113274
No description provided.