Fix #113044: Reset Fonts When Loading New Files #113104

Merged
Harley Acheson merged 1 commits from Harley/blender:Fix113044 into blender-v4.0-release 2023-10-03 01:21:10 +02:00
Member

Close user-loaded fonts when loading a new blend file so that the
global_font slots are not taken up by the old file's fonts.


We maintain the list of current fonts in an array called global_font. We add a font id to this when opening a font, and remove them with calls to BLF_unload, BLF_unload_id, and BLF_unload_all. However, when loading new blend files this array remains populated with the old files.

Therefore, as illustrated in #113044, if you start Blender, load a blend file that uses 40 unique fonts, then load a blend file containing 40 different fonts, you could get a "Too many fonts!!!" errror.

We clear the list in BLF_init(), called only from WM_init in main during program startup. We also clear the list in BLF_exit() from WM_exit when closing down. We don't want to close and reinitialize FreeType, nor do we want to call uiStyleInit (which also closes all fonts) as that can duplicate items in the uifonts list.

Basically we don't want to close all files anyway. This PR just closes the fonts not used by the UI. So ones that are not the current UI font, not the usual UI font, nor mono, nor anything in the font stack.

Close user-loaded fonts when loading a new blend file so that the global_font slots are not taken up by the old file's fonts. --- We maintain the list of current fonts in an array called `global_font`. We add a font id to this when opening a font, and remove them with calls to BLF_unload, BLF_unload_id, and BLF_unload_all. However, when loading new blend files this array remains populated with the old files. Therefore, as illustrated in #113044, if you start Blender, load a blend file that uses 40 unique fonts, then load a blend file containing 40 different fonts, you could get a "Too many fonts!!!" errror. We clear the list in BLF_init(), called only from WM_init in main during program startup. We also clear the list in BLF_exit() from WM_exit when closing down. We don't want to close and reinitialize FreeType, nor do we want to call `uiStyleInit` (which also closes all fonts) as that can duplicate items in the uifonts list. Basically we don't want to close all files anyway. This PR just closes the fonts not used by the UI. So ones that are not the current UI font, not the usual UI font, nor mono, nor anything in the font stack.
Harley Acheson added 1 commit 2023-10-01 05:30:39 +02:00
Fix #113044: Reset Fonts When Loading New Files
Some checks failed
buildbot/vexp-code-patch-coordinator Build done.
02ee5e22c9
Close user-loaded fonts when loading a new blend file so that the
global_font slots are not taken up by the old file's fonts.
Harley Acheson added this to the User Interface project 2023-10-01 05:30:51 +02:00
Harley Acheson requested review from Brecht Van Lommel 2023-10-01 05:30:58 +02:00
Harley Acheson changed title from Fix #113044: Reset Fonts When Loading New Files to Fix #113044: Reset Fonts When Loading New Files 2023-10-01 17:37:14 +02:00
Harley Acheson changed target branch from main to blender-v4.0-release 2023-10-01 17:37:16 +02:00
Brecht Van Lommel approved these changes 2023-10-02 14:12:26 +02:00
Author
Member

@blender-bot build

@blender-bot build
Harley Acheson merged commit e196f0a874 into blender-v4.0-release 2023-10-03 01:21:10 +02:00
Harley Acheson deleted branch Fix113044 2023-10-03 01:21:14 +02:00
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
Code Documentation
Interest
Collada
Interest
Compatibility
Interest
Compositing
Interest
Core
Interest
Cycles
Interest
Dependency Graph
Interest
Development Management
Interest
EEVEE
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
Viewport & EEVEE
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
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
Module
Viewport & EEVEE
Platform
FreeBSD
Platform
Linux
Platform
macOS
Platform
Windows
Severity
High
Severity
Low
Severity
Normal
Severity
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
2 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#113104
No description provided.