From 4e4697b1c481094949165fa9edbe6aeebcfcf3b4 Mon Sep 17 00:00:00 2001 From: Ibrahn Sahir Date: Fri, 5 Jul 2019 18:08:43 +0100 Subject: [PATCH] Added release function to PoolVector::Access. For clarity, assign-to-release idiom for PoolVector::Read/Write replaced with a function call. Existing uses replaced (or removed if already handled by scope) --- core/bind/core_bind.cpp | 8 +++++--- core/image.cpp | 10 +++++----- core/io/marshalls.cpp | 6 ------ core/io/resource_format_binary.cpp | 18 ++++++++--------- core/io/stream_peer.cpp | 4 ++-- core/math/triangle_mesh.cpp | 4 ++-- core/pool_vector.h | 4 ++++ core/variant.cpp | 3 --- core/variant_call.cpp | 4 ++-- drivers/gles2/rasterizer_storage_gles2.cpp | 8 ++++---- drivers/gles3/rasterizer_scene_gles3.cpp | 6 +++--- drivers/gles3/rasterizer_storage_gles3.cpp | 8 ++++---- editor/editor_profiler.cpp | 2 +- editor/plugins/editor_preview_plugins.cpp | 2 +- editor/plugins/multimesh_editor_plugin.cpp | 2 +- editor/plugins/particles_editor_plugin.cpp | 2 +- editor/plugins/tile_set_editor_plugin.cpp | 8 ++++---- modules/csg/csg_shape.cpp | 8 ++++---- modules/cvtt/image_compress_cvtt.cpp | 4 ++-- modules/dds/texture_loader_dds.cpp | 5 ----- modules/etc/texture_loader_pkm.cpp | 2 +- modules/jpg/image_loader_jpegd.cpp | 4 +--- modules/pvr/texture_loader_pvr.cpp | 6 +++--- modules/squish/image_compress_squish.cpp | 4 ++-- .../stb_vorbis/audio_stream_ogg_vorbis.cpp | 2 +- modules/svg/image_loader_svg.cpp | 2 +- modules/tga/image_loader_tga.cpp | 2 +- modules/tinyexr/image_loader_tinyexr.cpp | 2 +- modules/webp/image_loader_webp.cpp | 8 +++----- platform/android/java_godot_lib_jni.cpp | 8 ++++---- scene/2d/collision_polygon_2d.cpp | 2 +- scene/2d/tile_map.cpp | 2 +- scene/3d/soft_body.cpp | 2 +- scene/3d/sprite_3d.cpp | 2 +- scene/resources/animation.cpp | 20 +++++++++---------- scene/resources/dynamic_font_stb.cpp | 2 +- scene/resources/mesh.cpp | 8 ++++---- scene/resources/surface_tool.cpp | 14 ++++++------- servers/physics/shape_sw.cpp | 4 ++-- servers/physics_2d/shape_2d_sw.cpp | 2 +- servers/visual/visual_server_scene.cpp | 2 +- 41 files changed, 102 insertions(+), 114 deletions(-) diff --git a/core/bind/core_bind.cpp b/core/bind/core_bind.cpp index 1bf3425d506..34bbdb2c75f 100644 --- a/core/bind/core_bind.cpp +++ b/core/bind/core_bind.cpp @@ -1932,13 +1932,15 @@ PoolVector _File::get_buffer(int p_length) const { ERR_FAIL_COND_V(p_length < 0, data); if (p_length == 0) return data; + Error err = data.resize(p_length); ERR_FAIL_COND_V(err != OK, data); + PoolVector::Write w = data.write(); int len = f->get_buffer(&w[0], p_length); ERR_FAIL_COND_V(len < 0, PoolVector()); - w = PoolVector::Write(); + w.release(); if (len < p_length) data.resize(p_length); @@ -2113,11 +2115,11 @@ void _File::store_var(const Variant &p_var, bool p_full_objects) { PoolVector buff; buff.resize(len); - PoolVector::Write w = buff.write(); + PoolVector::Write w = buff.write(); err = encode_variant(p_var, &w[0], len, p_full_objects); ERR_FAIL_COND(err != OK); - w = PoolVector::Write(); + w.release(); store_32(len); store_buffer(buff); diff --git a/core/image.cpp b/core/image.cpp index 18a3aae88f6..a88395204af 100644 --- a/core/image.cpp +++ b/core/image.cpp @@ -495,8 +495,8 @@ void Image::convert(Format p_new_format) { case FORMAT_RGBA8 | (FORMAT_RGB8 << 8): _convert<3, true, 3, false, false, false>(width, height, rptr, wptr); break; } - r = PoolVector::Read(); - w = PoolVector::Write(); + r.release(); + w.release(); bool gen_mipmaps = mipmaps; @@ -1091,8 +1091,8 @@ void Image::resize(int p_width, int p_height, Interpolation p_interpolation) { } break; } - r = PoolVector::Read(); - w = PoolVector::Write(); + r.release(); + w.release(); if (interpolate_mipmaps) { dst._copy_internals_from(dst2); @@ -2394,7 +2394,7 @@ void Image::lock() { void Image::unlock() { - write_lock = PoolVector::Write(); + write_lock.release(); } Color Image::get_pixelv(const Point2 &p_src) const { diff --git a/core/io/marshalls.cpp b/core/io/marshalls.cpp index 17a3f52a65f..dc5581ea019 100644 --- a/core/io/marshalls.cpp +++ b/core/io/marshalls.cpp @@ -558,8 +558,6 @@ Error decode_variant(Variant &r_variant, const uint8_t *p_buffer, int p_len, int w[i] = buf[i]; } - - w = PoolVector::Write(); } r_variant = data; @@ -590,8 +588,6 @@ Error decode_variant(Variant &r_variant, const uint8_t *p_buffer, int p_len, int w[i] = decode_uint32(&buf[i * 4]); } - - w = PoolVector::Write(); } r_variant = Variant(data); if (r_len) { @@ -618,8 +614,6 @@ Error decode_variant(Variant &r_variant, const uint8_t *p_buffer, int p_len, int w[i] = decode_float(&buf[i * 4]); } - - w = PoolVector::Write(); } r_variant = data; diff --git a/core/io/resource_format_binary.cpp b/core/io/resource_format_binary.cpp index 688dfc21e51..861e34e415f 100644 --- a/core/io/resource_format_binary.cpp +++ b/core/io/resource_format_binary.cpp @@ -410,7 +410,7 @@ Error ResourceInteractiveLoaderBinary::parse_variant(Variant &r_v) { PoolVector::Write w = array.write(); f->get_buffer(w.ptr(), len); _advance_padding(len); - w = PoolVector::Write(); + w.release(); r_v = array; } break; @@ -432,7 +432,7 @@ Error ResourceInteractiveLoaderBinary::parse_variant(Variant &r_v) { } #endif - w = PoolVector::Write(); + w.release(); r_v = array; } break; case VARIANT_REAL_ARRAY: { @@ -454,7 +454,7 @@ Error ResourceInteractiveLoaderBinary::parse_variant(Variant &r_v) { #endif - w = PoolVector::Write(); + w.release(); r_v = array; } break; case VARIANT_STRING_ARRAY: { @@ -465,7 +465,7 @@ Error ResourceInteractiveLoaderBinary::parse_variant(Variant &r_v) { PoolVector::Write w = array.write(); for (uint32_t i = 0; i < len; i++) w[i] = get_unicode_string(); - w = PoolVector::Write(); + w.release(); r_v = array; } break; @@ -493,7 +493,7 @@ Error ResourceInteractiveLoaderBinary::parse_variant(Variant &r_v) { ERR_EXPLAIN("Vector2 size is NOT 8!"); ERR_FAIL_V(ERR_UNAVAILABLE); } - w = PoolVector::Write(); + w.release(); r_v = array; } break; @@ -521,7 +521,7 @@ Error ResourceInteractiveLoaderBinary::parse_variant(Variant &r_v) { ERR_EXPLAIN("Vector3 size is NOT 12!"); ERR_FAIL_V(ERR_UNAVAILABLE); } - w = PoolVector::Write(); + w.release(); r_v = array; } break; @@ -549,7 +549,7 @@ Error ResourceInteractiveLoaderBinary::parse_variant(Variant &r_v) { ERR_EXPLAIN("Color size is NOT 16!"); ERR_FAIL_V(ERR_UNAVAILABLE); } - w = PoolVector::Write(); + w.release(); r_v = array; } break; #ifndef DISABLE_DEPRECATED @@ -584,7 +584,7 @@ Error ResourceInteractiveLoaderBinary::parse_variant(Variant &r_v) { PoolVector::Write w = imgdata.write(); f->get_buffer(w.ptr(), datalen); _advance_padding(datalen); - w = PoolVector::Write(); + w.release(); Ref image; image.instance(); @@ -597,7 +597,7 @@ Error ResourceInteractiveLoaderBinary::parse_variant(Variant &r_v) { data.resize(f->get_32()); PoolVector::Write w = data.write(); f->get_buffer(w.ptr(), data.size()); - w = PoolVector::Write(); + w.release(); Ref image; diff --git a/core/io/stream_peer.cpp b/core/io/stream_peer.cpp index 6ad24a5f3a7..acf72dbba54 100644 --- a/core/io/stream_peer.cpp +++ b/core/io/stream_peer.cpp @@ -79,7 +79,7 @@ Array StreamPeer::_get_data(int p_bytes) { PoolVector::Write w = data.write(); Error err = get_data(&w[0], p_bytes); - w = PoolVector::Write(); + w.release(); ret.push_back(err); ret.push_back(data); return ret; @@ -101,7 +101,7 @@ Array StreamPeer::_get_partial_data(int p_bytes) { PoolVector::Write w = data.write(); int received; Error err = get_partial_data(&w[0], p_bytes, received); - w = PoolVector::Write(); + w.release(); if (err != OK) { data.resize(0); diff --git a/core/math/triangle_mesh.cpp b/core/math/triangle_mesh.cpp index 83784a1fa75..546981be44e 100644 --- a/core/math/triangle_mesh.cpp +++ b/core/math/triangle_mesh.cpp @@ -182,7 +182,7 @@ void TriangleMesh::create(const PoolVector &p_faces) { int max_alloc = fc; _create_bvh(bw.ptr(), bwp.ptr(), 0, fc, 1, max_depth, max_alloc); - bw = PoolVector::Write(); //clearup + bw.release(); //clearup bvh.resize(max_alloc); //resize back valid = true; @@ -751,7 +751,7 @@ PoolVector TriangleMesh::get_faces() const { } } - w = PoolVector::Write(); + w.release(); return faces; } diff --git a/core/pool_vector.h b/core/pool_vector.h index 338de966f63..aba66e39099 100644 --- a/core/pool_vector.h +++ b/core/pool_vector.h @@ -301,6 +301,10 @@ public: virtual ~Access() { _unref(); } + + void release() { + _unref(); + } }; class Read : public Access { diff --git a/core/variant.cpp b/core/variant.cpp index 5b51a4e5134..fe9623d068c 100644 --- a/core/variant.cpp +++ b/core/variant.cpp @@ -2418,9 +2418,6 @@ Variant::Variant(const PoolVector &p_face_array) { for (int j = 0; j < 3; j++) w[i * 3 + j] = r[i].vertex[j]; } - - r = PoolVector::Read(); - w = PoolVector::Write(); } type = NIL; diff --git a/core/variant_call.cpp b/core/variant_call.cpp index 4c3cbfa4849..3fdd18a6308 100644 --- a/core/variant_call.cpp +++ b/core/variant_call.cpp @@ -319,7 +319,7 @@ struct _VariantCall { retval.resize(len); PoolByteArray::Write w = retval.write(); copymem(w.ptr(), charstr.ptr(), len); - w = PoolVector::Write(); + w.release(); r_ret = retval; } @@ -334,7 +334,7 @@ struct _VariantCall { retval.resize(len); PoolByteArray::Write w = retval.write(); copymem(w.ptr(), charstr.ptr(), len); - w = PoolVector::Write(); + w.release(); r_ret = retval; } diff --git a/drivers/gles2/rasterizer_storage_gles2.cpp b/drivers/gles2/rasterizer_storage_gles2.cpp index b08202ae453..c591db4f3d6 100644 --- a/drivers/gles2/rasterizer_storage_gles2.cpp +++ b/drivers/gles2/rasterizer_storage_gles2.cpp @@ -807,7 +807,7 @@ Ref RasterizerStorageGLES2::texture_get_data(RID p_texture, int p_layer) } } - wb = PoolVector::Write(); + wb.release(); data.resize(data_size); @@ -871,7 +871,7 @@ Ref RasterizerStorageGLES2::texture_get_data(RID p_texture, int p_layer) glBindFramebuffer(GL_FRAMEBUFFER, 0); glDeleteFramebuffers(1, &temp_framebuffer); - wb = PoolVector::Write(); + wb.release(); data.resize(data_size); @@ -2155,8 +2155,8 @@ static PoolVector _unpack_half_floats(const PoolVector &array, dst_offset += dst_size[i]; } - r = PoolVector::Read(); - w = PoolVector::Write(); + r.release(); + w.release(); return ret; } diff --git a/drivers/gles3/rasterizer_scene_gles3.cpp b/drivers/gles3/rasterizer_scene_gles3.cpp index c2fde148e28..fb3d154a7a7 100644 --- a/drivers/gles3/rasterizer_scene_gles3.cpp +++ b/drivers/gles3/rasterizer_scene_gles3.cpp @@ -1459,8 +1459,8 @@ void RasterizerSceneGLES3::_setup_geometry(RenderList::Element *e, const Transfo #else PoolVector particle_vector; particle_vector.resize(particles->amount); - PoolVector::Write w = particle_vector.write(); - particle_array = w.ptr(); + PoolVector::Write particle_writer = particle_vector.write(); + particle_array = particle_writer.ptr(); glGetBufferSubData(GL_ARRAY_BUFFER, 0, particles->amount * sizeof(RasterizerGLES3Particle), particle_array); #endif @@ -1477,7 +1477,7 @@ void RasterizerSceneGLES3::_setup_geometry(RenderList::Element *e, const Transfo #ifndef __EMSCRIPTEN__ glUnmapBuffer(GL_ARRAY_BUFFER); #else - w = PoolVector::Write(); + particle_writer.release(); particle_array = NULL; { PoolVector::Read r = particle_vector.read(); diff --git a/drivers/gles3/rasterizer_storage_gles3.cpp b/drivers/gles3/rasterizer_storage_gles3.cpp index b2808981881..7efe6a987a7 100644 --- a/drivers/gles3/rasterizer_storage_gles3.cpp +++ b/drivers/gles3/rasterizer_storage_gles3.cpp @@ -1173,7 +1173,7 @@ Ref RasterizerStorageGLES3::texture_get_data(RID p_texture, int p_layer) glDeleteFramebuffers(1, &tmp_fbo); } - wb = PoolVector::Write(); + wb.release(); data.resize(data_size); @@ -1248,7 +1248,7 @@ Ref RasterizerStorageGLES3::texture_get_data(RID p_texture, int p_layer) img_format = real_format; } - wb = PoolVector::Write(); + wb.release(); data.resize(data_size); @@ -1316,7 +1316,7 @@ Ref RasterizerStorageGLES3::texture_get_data(RID p_texture, int p_layer) glBindFramebuffer(GL_FRAMEBUFFER, 0); glDeleteFramebuffers(1, &temp_framebuffer); - wb = PoolVector::Write(); + wb.release(); data.resize(data_size); @@ -6337,7 +6337,7 @@ AABB RasterizerStorageGLES3::particles_get_current_aabb(RID p_particles) { } #if defined(GLES_OVER_GL) || defined(__EMSCRIPTEN__) - r = PoolVector::Read(); + r.release(); vector = PoolVector(); #else glUnmapBuffer(GL_ARRAY_BUFFER); diff --git a/editor/editor_profiler.cpp b/editor/editor_profiler.cpp index 9cf36f162d4..471742948fc 100644 --- a/editor/editor_profiler.cpp +++ b/editor/editor_profiler.cpp @@ -340,7 +340,7 @@ void EditorProfiler::_update_plot() { } } - wr = PoolVector::Write(); + wr.release(); Ref img; img.instance(); diff --git a/editor/plugins/editor_preview_plugins.cpp b/editor/plugins/editor_preview_plugins.cpp index 285823d95ac..d260b171a83 100644 --- a/editor/plugins/editor_preview_plugins.cpp +++ b/editor/plugins/editor_preview_plugins.cpp @@ -676,7 +676,7 @@ Ref EditorAudioStreamPreviewPlugin::generate(const RES &p_from, const S } } - imgdata = PoolVector::Write(); + imgdata.release(); //post_process_preview(img); Ref ptex = Ref(memnew(ImageTexture)); diff --git a/editor/plugins/multimesh_editor_plugin.cpp b/editor/plugins/multimesh_editor_plugin.cpp index cae705a697c..d59efe49e7f 100644 --- a/editor/plugins/multimesh_editor_plugin.cpp +++ b/editor/plugins/multimesh_editor_plugin.cpp @@ -144,7 +144,7 @@ void MultiMeshEditor::_populate() { } } - w = PoolVector::Write(); + w.release(); PoolVector faces = geometry; ERR_EXPLAIN(TTR("Parent has no solid faces to populate.")); diff --git a/editor/plugins/particles_editor_plugin.cpp b/editor/plugins/particles_editor_plugin.cpp index f05e7d65d3c..75d31459e82 100644 --- a/editor/plugins/particles_editor_plugin.cpp +++ b/editor/plugins/particles_editor_plugin.cpp @@ -197,7 +197,7 @@ void ParticlesEditorBase::_node_selected(const NodePath &p_path) { } } - w = PoolVector::Write(); + w.release(); emission_dialog->popup_centered(Size2(300, 130)); } diff --git a/editor/plugins/tile_set_editor_plugin.cpp b/editor/plugins/tile_set_editor_plugin.cpp index 35cfdf15beb..2b59787f17e 100644 --- a/editor/plugins/tile_set_editor_plugin.cpp +++ b/editor/plugins/tile_set_editor_plugin.cpp @@ -1491,7 +1491,7 @@ void TileSetEditor::_on_workspace_input(const Ref &p_ie) { w[i] = current_shape[i] - shape_anchor; } - w = PoolVector::Write(); + w.release(); undo_redo->create_action(TTR("Edit Occlusion Polygon")); undo_redo->add_do_method(edited_occlusion_shape.ptr(), "set_polygon", polygon); @@ -1514,7 +1514,7 @@ void TileSetEditor::_on_workspace_input(const Ref &p_ie) { indices.push_back(i); } - w = PoolVector::Write(); + w.release(); undo_redo->create_action(TTR("Edit Navigation Polygon")); undo_redo->add_do_method(edited_navigation_shape.ptr(), "set_vertices", polygon); @@ -2785,7 +2785,7 @@ void TileSetEditor::close_shape(const Vector2 &shape_anchor) { w[i] = current_shape[i] - shape_anchor; } - w = PoolVector::Write(); + w.release(); shape->set_polygon(polygon); undo_redo->create_action(TTR("Create Occlusion Polygon")); @@ -2813,7 +2813,7 @@ void TileSetEditor::close_shape(const Vector2 &shape_anchor) { indices.push_back(i); } - w = PoolVector::Write(); + w.release(); shape->set_vertices(polygon); shape->add_polygon(indices); diff --git a/modules/csg/csg_shape.cpp b/modules/csg/csg_shape.cpp index 0a714dcc6c4..23725c4960e 100644 --- a/modules/csg/csg_shape.cpp +++ b/modules/csg/csg_shape.cpp @@ -436,10 +436,10 @@ void CSGShape::_update_shape() { } // unset write access - surfaces.write[i].verticesw = PoolVector::Write(); - surfaces.write[i].normalsw = PoolVector::Write(); - surfaces.write[i].uvsw = PoolVector::Write(); - surfaces.write[i].tansw = PoolVector::Write(); + surfaces.write[i].verticesw.release(); + surfaces.write[i].normalsw.release(); + surfaces.write[i].uvsw.release(); + surfaces.write[i].tansw.release(); if (surfaces[i].last_added == 0) continue; diff --git a/modules/cvtt/image_compress_cvtt.cpp b/modules/cvtt/image_compress_cvtt.cpp index 024e9ffc3b5..17b00387804 100644 --- a/modules/cvtt/image_compress_cvtt.cpp +++ b/modules/cvtt/image_compress_cvtt.cpp @@ -388,8 +388,8 @@ void image_decompress_cvtt(Image *p_image) { h >>= 1; } - rb = PoolVector::Read(); - wb = PoolVector::Write(); + rb.release(); + wb.release(); p_image->create(p_image->get_width(), p_image->get_height(), p_image->has_mipmaps(), target_format, data); } diff --git a/modules/dds/texture_loader_dds.cpp b/modules/dds/texture_loader_dds.cpp index 197b41b30c5..4628bd9a5be 100644 --- a/modules/dds/texture_loader_dds.cpp +++ b/modules/dds/texture_loader_dds.cpp @@ -251,7 +251,6 @@ RES ResourceFormatDDS::load(const String &p_path, const String &p_original_path, src_data.resize(size); PoolVector::Write wb = src_data.write(); f->get_buffer(wb.ptr(), size); - wb = PoolVector::Write(); } else if (info.palette) { @@ -296,8 +295,6 @@ RES ResourceFormatDDS::load(const String &p_path, const String &p_original_path, if (colsize == 4) wb[dst_ofs + 3] = palette[src_ofs + 3]; } - - wb = PoolVector::Write(); } else { //uncompressed generic... @@ -444,8 +441,6 @@ RES ResourceFormatDDS::load(const String &p_path, const String &p_original_path, default: { } } - - wb = PoolVector::Write(); } Ref img = memnew(Image(width, height, mipmaps - 1, info.format, src_data)); diff --git a/modules/etc/texture_loader_pkm.cpp b/modules/etc/texture_loader_pkm.cpp index f3028342224..ff925480b80 100644 --- a/modules/etc/texture_loader_pkm.cpp +++ b/modules/etc/texture_loader_pkm.cpp @@ -80,7 +80,7 @@ RES ResourceFormatPKM::load(const String &p_path, const String &p_original_path, src_data.resize(size); PoolVector::Write wb = src_data.write(); f->get_buffer(wb.ptr(), size); - wb = PoolVector::Write(); + wb.release(); int mipmaps = h.format; int width = h.origWidth; diff --git a/modules/jpg/image_loader_jpegd.cpp b/modules/jpg/image_loader_jpegd.cpp index 5493223cb0d..dcd8b8aebd1 100644 --- a/modules/jpg/image_loader_jpegd.cpp +++ b/modules/jpg/image_loader_jpegd.cpp @@ -96,7 +96,7 @@ Error jpeg_load_image_from_buffer(Image *p_image, const uint8_t *p_buffer, int p else fmt = Image::FORMAT_RGB8; - dw = PoolVector::Write(); + dw.release(); p_image->create(image_width, image_height, 0, fmt, data); return OK; @@ -117,8 +117,6 @@ Error ImageLoaderJPG::load_image(Ref p_image, FileAccess *f, bool p_force Error err = jpeg_load_image_from_buffer(p_image.ptr(), w.ptr(), src_image_len); - w = PoolVector::Write(); - return err; } diff --git a/modules/pvr/texture_loader_pvr.cpp b/modules/pvr/texture_loader_pvr.cpp index 8f6ffcc83f6..8b1f21d95dc 100644 --- a/modules/pvr/texture_loader_pvr.cpp +++ b/modules/pvr/texture_loader_pvr.cpp @@ -153,7 +153,7 @@ RES ResourceFormatPVR::load(const String &p_path, const String &p_original_path, ERR_FAIL_V(RES()); } - w = PoolVector::Write(); + w.release(); int tex_flags = Texture::FLAG_FILTER | Texture::FLAG_REPEAT; @@ -655,8 +655,8 @@ static void _pvrtc_decompress(Image *p_img) { decompress_pvrtc((PVRTCBlock *)r.ptr(), _2bit, p_img->get_width(), p_img->get_height(), 0, (unsigned char *)w.ptr()); - w = PoolVector::Write(); - r = PoolVector::Read(); + w.release(); + r.release(); bool make_mipmaps = p_img->has_mipmaps(); p_img->create(p_img->get_width(), p_img->get_height(), false, Image::FORMAT_RGBA8, newdata); diff --git a/modules/squish/image_compress_squish.cpp b/modules/squish/image_compress_squish.cpp index 4f38357aa1e..64f4c169cb3 100644 --- a/modules/squish/image_compress_squish.cpp +++ b/modules/squish/image_compress_squish.cpp @@ -198,8 +198,8 @@ void image_compress_squish(Image *p_image, float p_lossy_quality, Image::Compres h = MAX(h / 2, 1); } - rb = PoolVector::Read(); - wb = PoolVector::Write(); + rb.release(); + wb.release(); p_image->create(p_image->get_width(), p_image->get_height(), p_image->has_mipmaps(), target_format, data); } diff --git a/modules/stb_vorbis/audio_stream_ogg_vorbis.cpp b/modules/stb_vorbis/audio_stream_ogg_vorbis.cpp index b5f4718c722..0922471500e 100644 --- a/modules/stb_vorbis/audio_stream_ogg_vorbis.cpp +++ b/modules/stb_vorbis/audio_stream_ogg_vorbis.cpp @@ -188,7 +188,7 @@ void AudioStreamOGGVorbis::set_data(const PoolVector &p_data) { ogg_stream = stb_vorbis_open_memory((const unsigned char *)src_datar.ptr(), src_data_len, &error, &ogg_alloc); if (!ogg_stream && error == VORBIS_outofmem) { - w = PoolVector::Write(); + w.release(); alloc_try *= 2; } else { diff --git a/modules/svg/image_loader_svg.cpp b/modules/svg/image_loader_svg.cpp index e36844a1bc7..b0cd648734b 100644 --- a/modules/svg/image_loader_svg.cpp +++ b/modules/svg/image_loader_svg.cpp @@ -123,7 +123,7 @@ Error ImageLoaderSVG::_create_image(Ref p_image, const PoolVector::Write(); + dw.release(); p_image->create(w, h, false, Image::FORMAT_RGBA8, dst_image); if (upsample) p_image->shrink_x2(); diff --git a/modules/tga/image_loader_tga.cpp b/modules/tga/image_loader_tga.cpp index a3c0f5ded75..6ee408d4722 100644 --- a/modules/tga/image_loader_tga.cpp +++ b/modules/tga/image_loader_tga.cpp @@ -199,7 +199,7 @@ Error ImageLoaderTGA::convert_to_image(Ref p_image, const uint8_t *p_buff } } - image_data_w = PoolVector::Write(); + image_data_w.release(); p_image->create(width, height, 0, Image::FORMAT_RGBA8, image_data); diff --git a/modules/tinyexr/image_loader_tinyexr.cpp b/modules/tinyexr/image_loader_tinyexr.cpp index a9340b14987..74a584821a4 100644 --- a/modules/tinyexr/image_loader_tinyexr.cpp +++ b/modules/tinyexr/image_loader_tinyexr.cpp @@ -235,7 +235,7 @@ Error ImageLoaderTinyEXR::load_image(Ref p_image, FileAccess *f, bool p_f p_image->create(exr_image.width, exr_image.height, false, format, imgdata); - w = PoolVector::Write(); + w.release(); FreeEXRHeader(&exr_header); FreeEXRImage(&exr_image); diff --git a/modules/webp/image_loader_webp.cpp b/modules/webp/image_loader_webp.cpp index 928a0dcbd35..630c15f1401 100644 --- a/modules/webp/image_loader_webp.cpp +++ b/modules/webp/image_loader_webp.cpp @@ -71,7 +71,7 @@ static PoolVector _webp_lossy_pack(const Ref &p_image, float p_q w[3] = 'P'; copymem(&w[4], dst_buff, dst_size); free(dst_buff); - w = PoolVector::Write(); + w.release(); return dst; } @@ -110,7 +110,7 @@ static Ref _webp_lossy_unpack(const PoolVector &p_buffer) { //ERR_EXPLAIN("Error decoding webp! - "+p_file); ERR_FAIL_COND_V(errdec, Ref()); - dst_w = PoolVector::Write(); + dst_w.release(); Ref img = memnew(Image(features.width, features.height, 0, features.has_alpha ? Image::FORMAT_RGBA8 : Image::FORMAT_RGB8, dst_image)); return img; @@ -137,7 +137,7 @@ Error webp_load_image_from_buffer(Image *p_image, const uint8_t *p_buffer, int p } else { errdec = WebPDecodeRGBInto(p_buffer, p_buffer_len, dst_w.ptr(), datasize, 3 * features.width) == NULL; } - dst_w = PoolVector::Write(); + dst_w.release(); //ERR_EXPLAIN("Error decoding webp!"); ERR_FAIL_COND_V(errdec, ERR_FILE_CORRUPT); @@ -171,8 +171,6 @@ Error ImageLoaderWEBP::load_image(Ref p_image, FileAccess *f, bool p_forc Error err = webp_load_image_from_buffer(p_image.ptr(), w.ptr(), src_image_len); - w = PoolVector::Write(); - return err; } diff --git a/platform/android/java_godot_lib_jni.cpp b/platform/android/java_godot_lib_jni.cpp index 466f79c2151..77f077456e6 100644 --- a/platform/android/java_godot_lib_jni.cpp +++ b/platform/android/java_godot_lib_jni.cpp @@ -289,7 +289,7 @@ Variant _jobject_to_variant(JNIEnv *env, jobject obj) { PoolVector::Write w = sarr.write(); env->GetIntArrayRegion(arr, 0, fCount, w.ptr()); - w = PoolVector::Write(); + w.release(); return sarr; }; @@ -302,7 +302,7 @@ Variant _jobject_to_variant(JNIEnv *env, jobject obj) { PoolVector::Write w = sarr.write(); env->GetByteArrayRegion(arr, 0, fCount, reinterpret_cast(w.ptr())); - w = PoolVector::Write(); + w.release(); return sarr; }; @@ -514,7 +514,7 @@ public: PoolVector::Write w = sarr.write(); env->GetIntArrayRegion(arr, 0, fCount, w.ptr()); - w = PoolVector::Write(); + w.release(); ret = sarr; env->DeleteLocalRef(arr); } break; @@ -528,7 +528,7 @@ public: PoolVector::Write w = sarr.write(); env->GetFloatArrayRegion(arr, 0, fCount, w.ptr()); - w = PoolVector::Write(); + w.release(); ret = sarr; env->DeleteLocalRef(arr); } break; diff --git a/scene/2d/collision_polygon_2d.cpp b/scene/2d/collision_polygon_2d.cpp index ef7644fcab6..bb144dda96f 100644 --- a/scene/2d/collision_polygon_2d.cpp +++ b/scene/2d/collision_polygon_2d.cpp @@ -70,7 +70,7 @@ void CollisionPolygon2D::_build_polygon() { w[(i << 1) + 1] = polygon[(i + 1) % polygon.size()]; } - w = PoolVector::Write(); + w.release(); concave->set_segments(segments); parent->shape_owner_add_shape(owner_id, concave); diff --git a/scene/2d/tile_map.cpp b/scene/2d/tile_map.cpp index 22bc0e44e69..0a6d6304280 100644 --- a/scene/2d/tile_map.cpp +++ b/scene/2d/tile_map.cpp @@ -1275,7 +1275,7 @@ PoolVector TileMap::_get_tile_data() const { idx += 3; } - w = PoolVector::Write(); + w.release(); return data; } diff --git a/scene/3d/soft_body.cpp b/scene/3d/soft_body.cpp index b9f68652982..386e127f8bf 100644 --- a/scene/3d/soft_body.cpp +++ b/scene/3d/soft_body.cpp @@ -73,7 +73,7 @@ void SoftBodyVisualServerHandler::open() { } void SoftBodyVisualServerHandler::close() { - write_buffer = PoolVector::Write(); + write_buffer.release(); } void SoftBodyVisualServerHandler::commit_changes() { diff --git a/scene/3d/sprite_3d.cpp b/scene/3d/sprite_3d.cpp index 9f73484b6a6..d0f8799a649 100644 --- a/scene/3d/sprite_3d.cpp +++ b/scene/3d/sprite_3d.cpp @@ -254,7 +254,7 @@ Ref SpriteBase3D::generate_triangle_mesh() const { facesw[j] = vtx; } - facesw = PoolVector::Write(); + facesw.release(); triangle_mesh = Ref(memnew(TriangleMesh)); triangle_mesh->create(faces); diff --git a/scene/resources/animation.cpp b/scene/resources/animation.cpp index 1ca643cd7ad..89cbf0becd7 100644 --- a/scene/resources/animation.cpp +++ b/scene/resources/animation.cpp @@ -403,7 +403,7 @@ bool Animation::_get(const StringName &p_name, Variant &r_ret) const { w[idx++] = scale.z; } - w = PoolVector::Write(); + w.release(); r_ret = keys; return true; @@ -438,8 +438,8 @@ bool Animation::_get(const StringName &p_name, Variant &r_ret) const { idx++; } - wti = PoolVector::Write(); - wtr = PoolVector::Write(); + wti.release(); + wtr.release(); d["times"] = key_times; d["transitions"] = key_transitions; @@ -478,8 +478,8 @@ bool Animation::_get(const StringName &p_name, Variant &r_ret) const { idx++; } - wti = PoolVector::Write(); - wtr = PoolVector::Write(); + wti.release(); + wtr.release(); d["times"] = key_times; d["transitions"] = key_transitions; @@ -523,8 +523,8 @@ bool Animation::_get(const StringName &p_name, Variant &r_ret) const { idx++; } - wti = PoolVector::Write(); - wpo = PoolVector::Write(); + wti.release(); + wpo.release(); d["times"] = key_times; d["points"] = key_points; @@ -562,7 +562,7 @@ bool Animation::_get(const StringName &p_name, Variant &r_ret) const { idx++; } - wti = PoolVector::Write(); + wti.release(); d["times"] = key_times; d["clips"] = clips; @@ -595,8 +595,8 @@ bool Animation::_get(const StringName &p_name, Variant &r_ret) const { wcl[i] = vls[i].value; } - wti = PoolVector::Write(); - wcl = PoolVector::Write(); + wti.release(); + wcl.release(); d["times"] = key_times; d["clips"] = clips; diff --git a/scene/resources/dynamic_font_stb.cpp b/scene/resources/dynamic_font_stb.cpp index 3b44f05b944..ccff617a16a 100644 --- a/scene/resources/dynamic_font_stb.cpp +++ b/scene/resources/dynamic_font_stb.cpp @@ -55,7 +55,7 @@ void DynamicFontData::lock() { void DynamicFontData::unlock() { - fr = PoolVector::Read(); + fr.release(); } void DynamicFontData::set_font_data(const PoolVector &p_font) { diff --git a/scene/resources/mesh.cpp b/scene/resources/mesh.cpp index 6443b44bb65..aff274cd21e 100644 --- a/scene/resources/mesh.cpp +++ b/scene/resources/mesh.cpp @@ -98,7 +98,7 @@ Ref Mesh::generate_triangle_mesh() const { } } - facesw = PoolVector::Write(); + facesw.release(); triangle_mesh = Ref(memnew(TriangleMesh)); triangle_mesh->create(faces); @@ -436,7 +436,7 @@ Ref Mesh::create_outline(float p_margin) const { r[i] = t; } - r = PoolVector::Write(); + r.release(); arrays[ARRAY_VERTEX] = vertices; if (!has_indices) { @@ -452,7 +452,7 @@ Ref Mesh::create_outline(float p_margin) const { iw[j + 2] = j + 1; } - iw = PoolVector::Write(); + iw.release(); arrays[ARRAY_INDEX] = new_indices; } else { @@ -461,7 +461,7 @@ Ref Mesh::create_outline(float p_margin) const { SWAP(ir[j + 1], ir[j + 2]); } - ir = PoolVector::Write(); + ir.release(); arrays[ARRAY_INDEX] = indices; } } diff --git a/scene/resources/surface_tool.cpp b/scene/resources/surface_tool.cpp index 496b1b2bdc1..2588e41951e 100644 --- a/scene/resources/surface_tool.cpp +++ b/scene/resources/surface_tool.cpp @@ -307,7 +307,7 @@ Array SurfaceTool::commit_to_arrays() { } } - w = PoolVector::Write(); + w.release(); a[i] = array; } break; @@ -335,7 +335,7 @@ Array SurfaceTool::commit_to_arrays() { } } - w = PoolVector::Write(); + w.release(); a[i] = array; } break; case Mesh::ARRAY_TANGENT: { @@ -358,7 +358,7 @@ Array SurfaceTool::commit_to_arrays() { w[idx + 3] = d < 0 ? -1 : 1; } - w = PoolVector::Write(); + w.release(); a[i] = array; } break; @@ -375,7 +375,7 @@ Array SurfaceTool::commit_to_arrays() { w[idx] = v.color; } - w = PoolVector::Write(); + w.release(); a[i] = array; } break; case Mesh::ARRAY_BONES: { @@ -396,7 +396,7 @@ Array SurfaceTool::commit_to_arrays() { } } - w = PoolVector::Write(); + w.release(); a[i] = array; } break; @@ -418,7 +418,7 @@ Array SurfaceTool::commit_to_arrays() { } } - w = PoolVector::Write(); + w.release(); a[i] = array; } break; @@ -436,7 +436,7 @@ Array SurfaceTool::commit_to_arrays() { w[idx] = E->get(); } - w = PoolVector::Write(); + w.release(); a[i] = array; } break; diff --git a/servers/physics/shape_sw.cpp b/servers/physics/shape_sw.cpp index d40de669fd6..8a52f297299 100644 --- a/servers/physics/shape_sw.cpp +++ b/servers/physics/shape_sw.cpp @@ -1524,8 +1524,8 @@ void ConcavePolygonShapeSW::_setup(PoolVector p_faces) { _aabb.merge_with(bvh_arrayw[i].aabb); } - w = PoolVector::Write(); - vw = PoolVector::Write(); + w.release(); + vw.release(); int count = 0; _VolumeSW_BVH *bvh_tree = _volume_sw_build_bvh(bvh_arrayw, src_face_count, count); diff --git a/servers/physics_2d/shape_2d_sw.cpp b/servers/physics_2d/shape_2d_sw.cpp index 0043b948b0b..48799a56fbd 100644 --- a/servers/physics_2d/shape_2d_sw.cpp +++ b/servers/physics_2d/shape_2d_sw.cpp @@ -986,7 +986,7 @@ Variant ConcavePolygonShape2DSW::get_data() const { w[(i << 1) + 1] = points[segments[i].points[1]]; } - w = PoolVector::Write(); + w.release(); return rsegments; } diff --git a/servers/visual/visual_server_scene.cpp b/servers/visual/visual_server_scene.cpp index faf5a1f8fa8..7c100be0f28 100644 --- a/servers/visual/visual_server_scene.cpp +++ b/servers/visual/visual_server_scene.cpp @@ -2396,7 +2396,7 @@ void VisualServerScene::_setup_gi_probe(Instance *p_instance) { mipmap.resize(size); PoolVector::Write w = mipmap.write(); zeromem(w.ptr(), size); - w = PoolVector::Write(); + w.release(); probe->dynamic.mipmaps_3d.push_back(mipmap);