diff --git a/drivers/gles3/rasterizer_scene_gles3.cpp b/drivers/gles3/rasterizer_scene_gles3.cpp index 91c0693538d..c2fde148e28 100644 --- a/drivers/gles3/rasterizer_scene_gles3.cpp +++ b/drivers/gles3/rasterizer_scene_gles3.cpp @@ -4990,6 +4990,20 @@ bool RasterizerSceneGLES3::free(RID p_rid) { reflection_probe_instance_owner.free(p_rid); memdelete(reflection_instance); + } else if (environment_owner.owns(p_rid)) { + + Environment *environment = environment_owner.get(p_rid); + + environment_owner.free(p_rid); + memdelete(environment); + + } else if (gi_probe_instance_owner.owns(p_rid)) { + + GIProbeInstance *gi_probe_instance = gi_probe_instance_owner.get(p_rid); + + gi_probe_instance_owner.free(p_rid); + memdelete(gi_probe_instance); + } else { return false; } diff --git a/modules/gdnative/gdnative.cpp b/modules/gdnative/gdnative.cpp index a27935bfe2b..4eb9a2a0a3a 100644 --- a/modules/gdnative/gdnative.cpp +++ b/modules/gdnative/gdnative.cpp @@ -48,7 +48,7 @@ static const bool default_reloadable = true; // Defined in gdnative_api_struct.gen.cpp extern const godot_gdnative_core_api_struct api_struct; -Map > > *GDNativeLibrary::loaded_libraries = NULL; +Map > > GDNativeLibrary::loaded_libraries; GDNativeLibrary::GDNativeLibrary() { config_file.instance(); @@ -57,10 +57,6 @@ GDNativeLibrary::GDNativeLibrary() { load_once = default_load_once; singleton = default_singleton; reloadable = default_reloadable; - - if (GDNativeLibrary::loaded_libraries == NULL) { - GDNativeLibrary::loaded_libraries = memnew((Map > >)); - } } GDNativeLibrary::~GDNativeLibrary() { @@ -318,10 +314,10 @@ bool GDNative::initialize() { #endif if (library->should_load_once()) { - if (GDNativeLibrary::loaded_libraries->has(lib_path)) { + if (GDNativeLibrary::loaded_libraries.has(lib_path)) { // already loaded. Don't load again. // copy some of the stuff instead - this->native_handle = (*GDNativeLibrary::loaded_libraries)[lib_path][0]->native_handle; + this->native_handle = GDNativeLibrary::loaded_libraries[lib_path][0]->native_handle; initialized = true; return true; } @@ -377,11 +373,11 @@ bool GDNative::initialize() { initialized = true; - if (library->should_load_once() && !GDNativeLibrary::loaded_libraries->has(lib_path)) { + if (library->should_load_once() && !GDNativeLibrary::loaded_libraries.has(lib_path)) { Vector > gdnatives; gdnatives.resize(1); gdnatives.write[0] = Ref(this); - GDNativeLibrary::loaded_libraries->insert(lib_path, gdnatives); + GDNativeLibrary::loaded_libraries.insert(lib_path, gdnatives); } return true; @@ -395,7 +391,7 @@ bool GDNative::terminate() { } if (library->should_load_once()) { - Vector > *gdnatives = &(*GDNativeLibrary::loaded_libraries)[library->get_current_library_path()]; + Vector > *gdnatives = &GDNativeLibrary::loaded_libraries[library->get_current_library_path()]; if (gdnatives->size() > 1) { // there are other GDNative's still using this library, so we actually don't terminate gdnatives->erase(Ref(this)); @@ -405,7 +401,7 @@ bool GDNative::terminate() { // we're the last one, terminate! gdnatives->clear(); // whew this looks scary, but all it does is remove the entry completely - GDNativeLibrary::loaded_libraries->erase(GDNativeLibrary::loaded_libraries->find(library->get_current_library_path())); + GDNativeLibrary::loaded_libraries.erase(GDNativeLibrary::loaded_libraries.find(library->get_current_library_path())); } } diff --git a/modules/gdnative/gdnative.h b/modules/gdnative/gdnative.h index 005d1d2bffd..408af26753f 100644 --- a/modules/gdnative/gdnative.h +++ b/modules/gdnative/gdnative.h @@ -47,7 +47,7 @@ class GDNative; class GDNativeLibrary : public Resource { GDCLASS(GDNativeLibrary, Resource); - static Map > > *loaded_libraries; + static Map > > loaded_libraries; friend class GDNativeLibraryResourceLoader; friend class GDNative; diff --git a/platform/x11/context_gl_x11.cpp b/platform/x11/context_gl_x11.cpp index 9718b031643..d70b947fcc9 100644 --- a/platform/x11/context_gl_x11.cpp +++ b/platform/x11/context_gl_x11.cpp @@ -145,6 +145,7 @@ Error ContextGL_X11::initialize() { break; } } + XFree(fbc); ERR_FAIL_COND_V(!fbconfig, ERR_UNCONFIGURED); swa.background_pixmap = None; @@ -159,6 +160,7 @@ Error ContextGL_X11::initialize() { vi = glXGetVisualFromFBConfig(x11_display, fbc[0]); fbconfig = fbc[0]; + XFree(fbc); } int (*oldHandler)(Display *, XErrorEvent *) = XSetErrorHandler(&ctxErrorHandler); diff --git a/scene/2d/particles_2d.cpp b/scene/2d/particles_2d.cpp index 77598974200..93c12f0103a 100644 --- a/scene/2d/particles_2d.cpp +++ b/scene/2d/particles_2d.cpp @@ -410,6 +410,7 @@ Particles2D::Particles2D() { particles = VS::get_singleton()->particles_create(); + one_shot = false; // Needed so that set_emitting doesn't access uninitialized values set_emitting(true); set_one_shot(false); set_amount(8); diff --git a/scene/3d/gi_probe.cpp b/scene/3d/gi_probe.cpp index 414e932f619..a04f156d802 100644 --- a/scene/3d/gi_probe.cpp +++ b/scene/3d/gi_probe.cpp @@ -571,4 +571,5 @@ GIProbe::GIProbe() { } GIProbe::~GIProbe() { + VS::get_singleton()->free(gi_probe); } diff --git a/scene/3d/particles.cpp b/scene/3d/particles.cpp index 2bcd0eaa467..00a168fc399 100644 --- a/scene/3d/particles.cpp +++ b/scene/3d/particles.cpp @@ -411,6 +411,7 @@ Particles::Particles() { particles = VS::get_singleton()->particles_create(); set_base(particles); + one_shot = false; // Needed so that set_emitting doesn't access uninitialized values set_emitting(true); set_one_shot(false); set_amount(8); diff --git a/scene/3d/soft_body.cpp b/scene/3d/soft_body.cpp index a9d96292a1e..b9f68652982 100644 --- a/scene/3d/soft_body.cpp +++ b/scene/3d/soft_body.cpp @@ -712,6 +712,7 @@ SoftBody::SoftBody() : } SoftBody::~SoftBody() { + PhysicsServer::get_singleton()->free(physics_rid); } void SoftBody::reset_softbody_pin() { diff --git a/scene/animation/skeleton_ik.cpp b/scene/animation/skeleton_ik.cpp index 43c4b2aa515..7a1b10792b3 100644 --- a/scene/animation/skeleton_ik.cpp +++ b/scene/animation/skeleton_ik.cpp @@ -406,6 +406,7 @@ void SkeletonIK::_notification(int p_what) { switch (p_what) { case NOTIFICATION_ENTER_TREE: { skeleton = Object::cast_to(get_parent()); + set_process_priority(1); reload_chain(); } break; case NOTIFICATION_INTERNAL_PROCESS: { @@ -431,8 +432,6 @@ SkeletonIK::SkeletonIK() : skeleton(NULL), target_node_override(NULL), task(NULL) { - - set_process_priority(1); } SkeletonIK::~SkeletonIK() { diff --git a/scene/main/scene_tree.cpp b/scene/main/scene_tree.cpp index 0e7cec57a4a..0940a59a825 100644 --- a/scene/main/scene_tree.cpp +++ b/scene/main/scene_tree.cpp @@ -453,9 +453,6 @@ void SceneTree::init() { //_quit=false; initialized = true; - input_handled = false; - - pause = false; root->_set_tree(this); MainLoop::init(); @@ -1986,6 +1983,8 @@ SceneTree::SceneTree() { idle_process_time = 1; root = NULL; + input_handled = false; + pause = false; current_frame = 0; current_event = 0; tree_changed_name = "tree_changed"; diff --git a/servers/visual/visual_server_raster.cpp b/servers/visual/visual_server_raster.cpp index d45bda72b77..7aded4e8165 100644 --- a/servers/visual/visual_server_raster.cpp +++ b/servers/visual/visual_server_raster.cpp @@ -77,6 +77,8 @@ void VisualServerRaster::free(RID p_rid) { return; if (VSG::scene->free(p_rid)) return; + if (VSG::scene_render->free(p_rid)) + return; } /* EVENT QUEUING */