Skip to content

Commit

Permalink
filechooser: Fix memory leak when the app closes requests
Browse files Browse the repository at this point in the history
  • Loading branch information
swick committed Nov 1, 2024
1 parent f95c87d commit 7f46634
Showing 1 changed file with 10 additions and 11 deletions.
21 changes: 10 additions & 11 deletions src/file-chooser.c
Original file line number Diff line number Diff line change
Expand Up @@ -73,8 +73,10 @@ send_response_in_thread_func (GTask *task,
GCancellable *cancellable)
{
Request *request = task_data;
GVariantBuilder results;
GVariantBuilder ruris;
g_auto(GVariantBuilder) results =
G_VARIANT_BUILDER_INIT (G_VARIANT_TYPE_VARDICT);
g_auto(GVariantBuilder) ruris =
G_VARIANT_BUILDER_INIT (G_VARIANT_TYPE_STRING_ARRAY);
guint response;
GVariant *options;
DocumentFlags flags = DOCUMENT_FLAG_WRITABLE | DOCUMENT_FLAG_DIRECTORY;
Expand All @@ -83,9 +85,6 @@ send_response_in_thread_func (GTask *task,
GVariant *current_filter;
GVariant *writable;

g_variant_builder_init (&results, G_VARIANT_TYPE_VARDICT);
g_variant_builder_init (&ruris, G_VARIANT_TYPE_STRING_ARRAY);

REQUEST_AUTOLOCK (request);

if (GPOINTER_TO_INT (g_object_get_data (G_OBJECT (request), "for-save")) == TRUE)
Expand Down Expand Up @@ -531,14 +530,14 @@ handle_open_file (XdpDbusFileChooser *object,
const char *app_id = xdp_app_info_get_id (request->app_info);
g_autoptr(GError) error = NULL;
g_autoptr(XdpDbusImplRequest) impl_request = NULL;
GVariantBuilder options;
g_auto(GVariantBuilder) options =
G_VARIANT_BUILDER_INIT (G_VARIANT_TYPE_VARDICT);
g_autoptr(GVariant) dir_option = NULL;

g_debug ("Handling OpenFile");

REQUEST_AUTOLOCK (request);

g_variant_builder_init (&options, G_VARIANT_TYPE_VARDICT);
if (!xdp_filter_options (arg_options, &options,
open_file_options, G_N_ELEMENTS (open_file_options),
&error))
Expand Down Expand Up @@ -660,7 +659,8 @@ handle_save_file (XdpDbusFileChooser *object,
const char *app_id = xdp_app_info_get_id (request->app_info);
g_autoptr(GError) error = NULL;
XdpDbusImplRequest *impl_request;
GVariantBuilder options;
g_auto(GVariantBuilder) options =
G_VARIANT_BUILDER_INIT (G_VARIANT_TYPE_VARDICT);

g_debug ("Handling SaveFile");

Expand All @@ -676,7 +676,6 @@ handle_save_file (XdpDbusFileChooser *object,

REQUEST_AUTOLOCK (request);

g_variant_builder_init (&options, G_VARIANT_TYPE_VARDICT);
if (!xdp_filter_options (arg_options, &options,
save_file_options, G_N_ELEMENTS (save_file_options),
&error))
Expand Down Expand Up @@ -819,7 +818,8 @@ handle_save_files (XdpDbusFileChooser *object,
const char *app_id = xdp_app_info_get_id (request->app_info);
g_autoptr(GError) error = NULL;
XdpDbusImplRequest *impl_request;
GVariantBuilder options;
g_auto(GVariantBuilder) options =
G_VARIANT_BUILDER_INIT (G_VARIANT_TYPE_VARDICT);

if (xdp_dbus_impl_lockdown_get_disable_save_to_disk (lockdown))
{
Expand All @@ -833,7 +833,6 @@ handle_save_files (XdpDbusFileChooser *object,

REQUEST_AUTOLOCK (request);

g_variant_builder_init (&options, G_VARIANT_TYPE_VARDICT);
if (!xdp_filter_options (arg_options, &options,
save_files_options, G_N_ELEMENTS (save_files_options),
&error))
Expand Down

0 comments on commit 7f46634

Please sign in to comment.