summaryrefslogtreecommitdiff
path: root/scene/2d/canvas_item.cpp
diff options
context:
space:
mode:
authorIbrahn Sahir <ibrahn.sahir@gmail.com>2018-11-21 15:48:05 +0000
committerIbrahn Sahir <ibrahn.sahir@gmail.com>2018-11-21 15:51:50 +0000
commitc1f5233217f35d59849fc920f4147f9a8b3f0885 (patch)
treeb631e42da562f3a8236bf6610629724967f94c42 /scene/2d/canvas_item.cpp
parent03bd4d28a541c626e9ad70e4520a17b6f45e900a (diff)
Moved dirty material lists from static to lifetime controlled by main.
As with 7d82bed4f4cac8f5227d935c0496290e24eb48c8, The list is now destroyed before the OS object, so can print errors if there are unfreed materials.
Diffstat (limited to 'scene/2d/canvas_item.cpp')
-rw-r--r--scene/2d/canvas_item.cpp15
1 files changed, 10 insertions, 5 deletions
diff --git a/scene/2d/canvas_item.cpp b/scene/2d/canvas_item.cpp
index 0ea2e85dfa..698bbf41ea 100644
--- a/scene/2d/canvas_item.cpp
+++ b/scene/2d/canvas_item.cpp
@@ -42,7 +42,7 @@
#include "servers/visual_server.h"
Mutex *CanvasItemMaterial::material_mutex = NULL;
-SelfList<CanvasItemMaterial>::List CanvasItemMaterial::dirty_materials;
+SelfList<CanvasItemMaterial>::List *CanvasItemMaterial::dirty_materials = NULL;
Map<CanvasItemMaterial::MaterialKey, CanvasItemMaterial::ShaderData> CanvasItemMaterial::shader_map;
CanvasItemMaterial::ShaderNames *CanvasItemMaterial::shader_names = NULL;
@@ -52,6 +52,8 @@ void CanvasItemMaterial::init_shaders() {
material_mutex = Mutex::create();
#endif
+ dirty_materials = memnew(SelfList<CanvasItemMaterial>::List);
+
shader_names = memnew(ShaderNames);
shader_names->particles_anim_h_frames = "particles_anim_h_frames";
@@ -61,6 +63,9 @@ void CanvasItemMaterial::init_shaders() {
void CanvasItemMaterial::finish_shaders() {
+ memdelete(dirty_materials);
+ dirty_materials = NULL;
+
#ifndef NO_THREADS
memdelete(material_mutex);
#endif
@@ -68,7 +73,7 @@ void CanvasItemMaterial::finish_shaders() {
void CanvasItemMaterial::_update_shader() {
- dirty_materials.remove(&element);
+ dirty_materials->remove(&element);
MaterialKey mk = _compute_key();
if (mk.key == current_key.key)
@@ -157,9 +162,9 @@ void CanvasItemMaterial::flush_changes() {
if (material_mutex)
material_mutex->lock();
- while (dirty_materials.first()) {
+ while (dirty_materials->first()) {
- dirty_materials.first()->self()->_update_shader();
+ dirty_materials->first()->self()->_update_shader();
}
if (material_mutex)
@@ -172,7 +177,7 @@ void CanvasItemMaterial::_queue_shader_change() {
material_mutex->lock();
if (!element.in_list()) {
- dirty_materials.add(&element);
+ dirty_materials->add(&element);
}
if (material_mutex)