context.annotation_data isn't set to nullptr when the last annotation layer is deleted #112683

Closed
opened 2023-09-21 18:56:18 +02:00 by Milan Davidović · 6 comments
Contributor

System Information
Operating system: Windows 10 Pro
Graphics card: NVIDIA GeForce GTX 1060 3GB/PCIe/SSE2

Blender Version
Broken: 3.6.2, branch: blender-v3.6-release, commit date: 2023-08-16 16:43, hash: e53e55951e, type: release

Short description of error
When the last Annotation layer is deleted from the list, there are warnings printed out to the console on each viewport update.
Looks like context.annotation_data isn't set to nullptr when the last annotation layer is deleted.

Exact steps for others to reproduce the error

  1. Start with the default empty scene.
  2. If the console isn't already visible, open it with Window -> Toggle System Console.
  3. In the 3D viewport, select the Annotate tool and draw a line with it.
  4. In the Tool Settings, open the annotation layers popup and delete the single existing layer named 'Note'.
  5. A few same warnings will be printed out in the console, and again on each update of the viewport:

WARN (bpy.rna): D:\Work\Projects\blender-git\blender\source\blender\python\intern\bpy_rna.cc:1349 pyrna_enum_to_py: current value '-1' matches no enum in 'GreasePencilLayers', '(null)', 'active_note'

**System Information** Operating system: Windows 10 Pro Graphics card: NVIDIA GeForce GTX 1060 3GB/PCIe/SSE2 **Blender Version** Broken: 3.6.2, branch: blender-v3.6-release, commit date: 2023-08-16 16:43, hash: e53e55951e7a, type: release **Short description of error** When the last Annotation layer is deleted from the list, there are warnings printed out to the console on each viewport update. Looks like context.annotation_data isn't set to nullptr when the last annotation layer is deleted. **Exact steps for others to reproduce the error** 1. Start with the default empty scene. 2. If the console isn't already visible, open it with Window -> Toggle System Console. 3. In the 3D viewport, select the Annotate tool and draw a line with it. 4. In the Tool Settings, open the annotation layers popup and delete the single existing layer named 'Note'. 5. A few same warnings will be printed out in the console, and again on each update of the viewport: `WARN (bpy.rna): D:\Work\Projects\blender-git\blender\source\blender\python\intern\bpy_rna.cc:1349 pyrna_enum_to_py: current value '-1' matches no enum in 'GreasePencilLayers', '(null)', 'active_note' `
Milan Davidović added the
Status
Needs Triage
Priority
Normal
Type
Report
labels 2023-09-21 18:56:19 +02:00
Author
Contributor

I'm already looking into this.

I'm already looking into this.
Member

Can reproduce on 3.6.2 and 4.0. The error will be printed any time the tool options header updates, suggesting somewhere in the UI script it needs to handle a null-layer situation.

Can reproduce on 3.6.2 and 4.0. The error will be printed any time the tool options header updates, suggesting somewhere in the UI script it needs to handle a null-layer situation.
YimingWu added
Status
Confirmed
and removed
Status
Needs Triage
labels 2023-09-22 04:59:07 +02:00
Author
Contributor

The UI script seems to handle null-layer situation well, but it seems that after deleting the last layer the annotation data bGPdata in C code hasn't been freed and that the script can still access it.

If I print messages in _defs_annotate.draw_settings_common like so:

image

Initially, when I select the annotation tool, only the first message is printed ("in draw_settings_common").

When I draw something, all three messages are printed.

But when I delete the last layer, all three messages still get printed out (together with that warning), meaning that the bGPdata hasn't been freed and the pointer set to null.

image

When I do this at the end of gpencil_layer_remove_exec():

  if (gpd->layers.first == nullptr) {
    bGPdata **gpd_ptr = ED_annotation_data_get_pointers(C, nullptr);
    *gpd_ptr = nullptr;
  }

... the problem disappears, but I leak memory. I'll just need to figure out how to free everything properly (I'm new to the code base so it's not that obvious what I need to do, but I'll manage).

The UI script seems to handle null-layer situation well, but it seems that after deleting the last layer the annotation data bGPdata in C code hasn't been freed and that the script can still access it. If I print messages in _defs_annotate.draw_settings_common like so: ![image](/attachments/3e8757dc-2ebd-401e-a964-9a423f0678c0) Initially, when I select the annotation tool, only the first message is printed ("in draw_settings_common"). When I draw something, all three messages are printed. But when I delete the last layer, all three messages still get printed out (together with that warning), meaning that the bGPdata hasn't been freed and the pointer set to null. ![image](/attachments/4cfc17c1-de60-49a8-b63d-a8676e17d323) When I do this at the end of gpencil_layer_remove_exec(): ``` if (gpd->layers.first == nullptr) { bGPdata **gpd_ptr = ED_annotation_data_get_pointers(C, nullptr); *gpd_ptr = nullptr; } ``` ... the problem disappears, but I leak memory. I'll just need to figure out how to free everything properly (I'm new to the code base so it's not that obvious what I need to do, but I'll manage).
Jesse Yurkovich added the
Module
Grease Pencil
label 2023-10-04 04:39:40 +02:00
Blender Bot added
Status
Resolved
and removed
Status
Confirmed
labels 2023-10-22 07:39:46 +02:00

And this can be backported to 3.6?

And this can be backported to 3.6?
Author
Contributor

I believe so, but I'm not familiar with the procedure. @PratikPB2123?

I believe so, but I'm not familiar with the procedure. @PratikPB2123?
Member

Thanks, added in both 3.3-3.6 backporting lists: #109399 / #100749

Thanks, added in both 3.3-3.6 backporting lists: #109399 / #100749
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
4 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#112683
No description provided.