Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Small cleanups for the File Transfer portal code #1574

Open
wants to merge 4 commits into
base: main
Choose a base branch
from
Open
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 3 additions & 4 deletions document-portal/file-transfer.c
Original file line number Diff line number Diff line change
Expand Up @@ -144,15 +144,15 @@ static GHashTable *transfers;
static FileTransfer *
lookup_transfer (const char *key)
{
FileTransfer *transfer;
g_autoptr(FileTransfer) transfer = NULL;

G_LOCK (transfers);
transfer = (FileTransfer *)g_hash_table_lookup (transfers, key);
if (transfer)
g_object_ref (transfer);
G_UNLOCK (transfers);

return transfer;
return g_steal_pointer (&transfer);
Comment on lines -147 to +156
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

transfer actually isn't owning the FileTransfer for some time which is a bit awkward. Maybe it gets more readable by ref-ing at the return?

  FileTransfer *transfer;

  G_LOCK (transfers);
  transfer = (FileTransfer *)g_hash_table_lookup (transfers, key);
  G_UNLOCK (transfers);
  
  if (!transfer)
    return NULL;

  return g_object_ref (transfer);

}

static FileTransfer *
Expand Down Expand Up @@ -583,10 +583,9 @@ stop_file_transfers_in_thread_func (GTask *task,
void
stop_file_transfers_for_sender (const char *sender)
{
GTask *task;
g_autoptr(GTask) task = NULL;

task = g_task_new (NULL, NULL, NULL, NULL);
g_task_set_task_data (task, g_strdup (sender), g_free);
g_task_run_in_thread (task, stop_file_transfers_in_thread_func);
g_object_unref (task);
}