[ghex/expand-search-options: 14/14] findrep: Cleanup and properly free GTask
- From: Logan Rathbone <larathbone src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [ghex/expand-search-options: 14/14] findrep: Cleanup and properly free GTask
- Date: Tue, 19 Apr 2022 22:04:08 +0000 (UTC)
commit 628056be1c673b1fe28526455e0bb1604ddf695b
Author: Logan Rathbone <poprocks gmail com>
Date: Tue Apr 19 18:00:53 2022 -0400
findrep: Cleanup and properly free GTask
src/findreplace.c | 12 ++++--------
src/hex-document.c | 1 +
2 files changed, 5 insertions(+), 8 deletions(-)
---
diff --git a/src/findreplace.c b/src/findreplace.c
index cd74f26..20a77a6 100644
--- a/src/findreplace.c
+++ b/src/findreplace.c
@@ -243,13 +243,13 @@ find_ready_cb (GObject *source_object,
HexDocument *doc = HEX_DOCUMENT (source_object);
FindDialog *self = FIND_DIALOG (user_data);
HexDocumentFindData *find_data;
+ GTask *task = G_TASK(res);
PaneDialogPrivate *priv = pane_dialog_get_instance_private (PANE_DIALOG(self));
FindDialogPrivate *f_priv = find_dialog_get_instance_private (self);
GtkWindow *parent = GTK_WINDOW(gtk_widget_get_native (GTK_WIDGET(self)));
HexSearchFlags flags;
find_data = hex_document_find_finish (doc, res);
- g_object_unref (res);
/* Typically this will be due to a cancellation - could theoretically be
* an error, but not much we can do to report a search error anyway.
@@ -284,11 +284,10 @@ find_ready_cb (GObject *source_object,
f_priv->found = FALSE;
}
-
-out:
- // FIXME - g_free find_data ?
mark_gh_busy (priv->gh, FALSE);
pane_dialog_update_busy_state (PANE_DIALOG(self));
+out:
+ g_object_unref (task);
}
static void
@@ -303,14 +302,12 @@ find_common (FindDialog *self, enum FindDirection direction,
gint64 cursor_pos;
gint64 str_len;
char *str;
- HexDocumentFindData *find_data;
+ HexDocumentFindData *find_data = NULL;
g_return_if_fail (FIND_IS_DIALOG(self));
priv = pane_dialog_get_instance_private (PANE_DIALOG(self));
- g_return_if_fail (HEX_IS_WIDGET (priv->gh));
f_priv = find_dialog_get_instance_private (self);
- g_return_if_fail (HEX_IS_DOCUMENT (f_priv->f_doc));
parent = GTK_WINDOW(gtk_widget_get_native (widget));
@@ -357,7 +354,6 @@ find_common (FindDialog *self, enum FindDirection direction,
find_ready_cb,
self);
}
-
mark_gh_busy (priv->gh, TRUE);
pane_dialog_update_busy_state (PANE_DIALOG(self));
}
diff --git a/src/hex-document.c b/src/hex-document.c
index 92f5e93..4fd189a 100644
--- a/src/hex-document.c
+++ b/src/hex-document.c
@@ -1402,6 +1402,7 @@ FUNC_NAME (HexDocument *doc, \
g_task_set_return_on_cancel (task, TRUE); \
g_task_set_task_data (task, find_data, g_free); \
g_task_run_in_thread (task, FUNC_TO_CALL); \
+ g_object_unref (task); /* _run_in_thread takes a ref */ \
}
FIND_ASYNC_TEMPLATE(hex_document_find_forward_async,
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]