summaryrefslogtreecommitdiff
path: root/servers
diff options
context:
space:
mode:
authorJuan Linietsky <reduzio@gmail.com>2015-04-20 19:38:02 -0300
committerJuan Linietsky <reduzio@gmail.com>2015-04-20 19:38:02 -0300
commit59154cccf9fcf814a21a2596993fb1b6777d3bb7 (patch)
tree4132620a9d924463dae4b64fea2dde68a14023e7 /servers
parent28c4afeb5733f9ca9725ab2a5f4066af8e02b2a6 (diff)
-Changed Godot exit to be clean.
-Added more debug information on memory cleanliness on exit (if run with -v) -Fixed several memory leaks, fixes #1731, fixes #755
Diffstat (limited to 'servers')
-rw-r--r--servers/visual/rasterizer.h1
-rw-r--r--servers/visual/visual_server_raster.cpp10
-rw-r--r--servers/visual_server.cpp33
-rw-r--r--servers/visual_server.h2
4 files changed, 36 insertions, 10 deletions
diff --git a/servers/visual/rasterizer.h b/servers/visual/rasterizer.h
index f0a67e8442..81862fb3a6 100644
--- a/servers/visual/rasterizer.h
+++ b/servers/visual/rasterizer.h
@@ -661,6 +661,7 @@ public:
};
Type type;
+ virtual ~Command(){}
};
struct CommandLine : public Command {
diff --git a/servers/visual/visual_server_raster.cpp b/servers/visual/visual_server_raster.cpp
index eaa02df516..2417c02bf8 100644
--- a/servers/visual/visual_server_raster.cpp
+++ b/servers/visual/visual_server_raster.cpp
@@ -4393,7 +4393,7 @@ void VisualServerRaster::free( RID p_rid ) {
VS_CHANGED;
- if (rasterizer->is_texture(p_rid) || rasterizer->is_material(p_rid) || rasterizer->is_shader(p_rid)) {
+ if (rasterizer->is_texture(p_rid) || rasterizer->is_material(p_rid) || rasterizer->is_shader(p_rid) || rasterizer->is_environment(p_rid)) {
rasterizer->free(p_rid);
} else if (rasterizer->is_skeleton(p_rid)) {
@@ -4410,7 +4410,7 @@ void VisualServerRaster::free( RID p_rid ) {
}
rasterizer->free(p_rid);
- } else if (rasterizer->is_mesh(p_rid) || rasterizer->is_multimesh(p_rid) || rasterizer->is_light(p_rid) || rasterizer->is_particles(p_rid) ) {
+ } else if (rasterizer->is_mesh(p_rid) || rasterizer->is_multimesh(p_rid) || rasterizer->is_light(p_rid) || rasterizer->is_particles(p_rid) || rasterizer->is_immediate(p_rid)) {
//delete the resource
_free_attached_instances(p_rid);
@@ -7488,6 +7488,10 @@ void VisualServerRaster::finish() {
free(default_cursor_texture);
+ if (test_cube.is_valid())
+ free(test_cube);
+
+ _free_internal_rids();
_clean_up_owner( &room_owner,"Room" );
_clean_up_owner( &portal_owner,"Portal" );
@@ -7505,7 +7509,7 @@ void VisualServerRaster::finish() {
octree_allocator.clear();
if (instance_dependency_map.size()) {
- print_line("base resources missing "+itos(instance_dependency_map.size()));
+ print_line("Base resources missing amount: "+itos(instance_dependency_map.size()));
}
ERR_FAIL_COND( instance_dependency_map.size() );
}
diff --git a/servers/visual_server.cpp b/servers/visual_server.cpp
index a49b3eca32..78320f277e 100644
--- a/servers/visual_server.cpp
+++ b/servers/visual_server.cpp
@@ -130,6 +130,24 @@ RID VisualServer::get_test_texture() {
return test_texture;
};
+void VisualServer::_free_internal_rids() {
+
+ if (test_texture.is_valid())
+ free(test_texture);
+ if (white_texture.is_valid())
+ free(white_texture);
+ if (test_material.is_valid())
+ free(test_material);
+
+ for(int i=0;i<16;i++) {
+ if (material_2d[i].is_valid())
+ free(material_2d[i]);
+ }
+
+
+
+}
+
RID VisualServer::_make_test_cube() {
DVector<Vector3> vertices;
@@ -202,16 +220,17 @@ RID VisualServer::_make_test_cube() {
mesh_add_surface( test_cube, PRIMITIVE_TRIANGLES,d );
- RID material = fixed_material_create();
+
+ test_material = fixed_material_create();
//material_set_flag(material, MATERIAL_FLAG_BILLBOARD_TOGGLE,true);
- fixed_material_set_texture( material, FIXED_MATERIAL_PARAM_DIFFUSE, get_test_texture() );
- fixed_material_set_param( material, FIXED_MATERIAL_PARAM_SPECULAR_EXP, 70 );
- fixed_material_set_param( material, FIXED_MATERIAL_PARAM_EMISSION, Color(0.2,0.2,0.2) );
+ fixed_material_set_texture( test_material, FIXED_MATERIAL_PARAM_DIFFUSE, get_test_texture() );
+ fixed_material_set_param( test_material, FIXED_MATERIAL_PARAM_SPECULAR_EXP, 70 );
+ fixed_material_set_param( test_material, FIXED_MATERIAL_PARAM_EMISSION, Color(0.2,0.2,0.2) );
- fixed_material_set_param( material, FIXED_MATERIAL_PARAM_DIFFUSE, Color(1, 1, 1) );
- fixed_material_set_param( material, FIXED_MATERIAL_PARAM_SPECULAR, Color(1,1,1) );
+ fixed_material_set_param( test_material, FIXED_MATERIAL_PARAM_DIFFUSE, Color(1, 1, 1) );
+ fixed_material_set_param( test_material, FIXED_MATERIAL_PARAM_SPECULAR, Color(1,1,1) );
- mesh_surface_set_material(test_cube, 0, material );
+ mesh_surface_set_material(test_cube, 0, test_material );
return test_cube;
}
diff --git a/servers/visual_server.h b/servers/visual_server.h
index e962cf4ea0..c1c2ef4fd3 100644
--- a/servers/visual_server.h
+++ b/servers/visual_server.h
@@ -55,8 +55,10 @@ class VisualServer : public Object {
void _canvas_item_add_style_box(RID p_item, const Rect2& p_rect, RID p_texture,const Vector<float>& p_margins, const Color& p_modulate=Color(1,1,1));
protected:
RID _make_test_cube();
+ void _free_internal_rids();
RID test_texture;
RID white_texture;
+ RID test_material;
RID material_2d[16];
static VisualServer* (*create_func)();