fix: memory leak on Linux
This commit is contained in:
parent
e118e96341
commit
4bdb5b430e
2 changed files with 5 additions and 2 deletions
|
|
@ -54,6 +54,7 @@ static gboolean texture_rgba_populate(FlTextureGL *texture,
|
||||||
// Note that Flutter only accepts textures in GL_RGBA8 format.
|
// Note that Flutter only accepts textures in GL_RGBA8 format.
|
||||||
glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA8, self->video_width, self->video_height, 0, GL_RGBA,
|
glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA8, self->video_width, self->video_height, 0, GL_RGBA,
|
||||||
GL_UNSIGNED_BYTE, self->buffer);
|
GL_UNSIGNED_BYTE, self->buffer);
|
||||||
|
delete[] self->buffer;
|
||||||
self->buffer = nullptr;
|
self->buffer = nullptr;
|
||||||
g_mutex_unlock(&self->mutex);
|
g_mutex_unlock(&self->mutex);
|
||||||
*target = GL_TEXTURE_2D;
|
*target = GL_TEXTURE_2D;
|
||||||
|
|
@ -61,7 +62,6 @@ static gboolean texture_rgba_populate(FlTextureGL *texture,
|
||||||
*width = self->video_width;
|
*width = self->video_width;
|
||||||
*height = self->video_height;
|
*height = self->video_height;
|
||||||
|
|
||||||
|
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -65,8 +65,8 @@ static void texture_rgba_renderer_plugin_handle_method_call(
|
||||||
if (self->g_renderer_map->find(key) != self->g_renderer_map->end())
|
if (self->g_renderer_map->find(key) != self->g_renderer_map->end())
|
||||||
{
|
{
|
||||||
fl_texture_registrar_unregister_texture(self->texture_registrar, FL_TEXTURE((*self->g_renderer_map)[key]));
|
fl_texture_registrar_unregister_texture(self->texture_registrar, FL_TEXTURE((*self->g_renderer_map)[key]));
|
||||||
}
|
|
||||||
self->g_renderer_map->erase(key);
|
self->g_renderer_map->erase(key);
|
||||||
|
}
|
||||||
response = FL_METHOD_RESPONSE(fl_method_success_response_new(fl_value_new_bool(true)));
|
response = FL_METHOD_RESPONSE(fl_method_success_response_new(fl_value_new_bool(true)));
|
||||||
}
|
}
|
||||||
else if (strcmp(method, "onRgba") == 0)
|
else if (strcmp(method, "onRgba") == 0)
|
||||||
|
|
@ -169,6 +169,9 @@ extern "C" {
|
||||||
priv->buffer_length = 4 * width * height;
|
priv->buffer_length = 4 * width * height;
|
||||||
auto copied_data = new uint8_t[priv->buffer_length];
|
auto copied_data = new uint8_t[priv->buffer_length];
|
||||||
memcpy(copied_data, buffer, priv->buffer_length);
|
memcpy(copied_data, buffer, priv->buffer_length);
|
||||||
|
if (priv->buffer != nullptr) {
|
||||||
|
delete[] priv->buffer;
|
||||||
|
}
|
||||||
priv->buffer = copied_data;
|
priv->buffer = copied_data;
|
||||||
priv->video_height = height;
|
priv->video_height = height;
|
||||||
priv->video_width = width;
|
priv->video_width = width;
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue