[nautilus] view-model: Fix clearing signal handler on sort change
- From: António Fernandes <antoniof src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [nautilus] view-model: Fix clearing signal handler on sort change
- Date: Mon, 1 Aug 2022 07:18:06 +0000 (UTC)
commit e12bc236e5b8de6772b321133f7e85378e59afda
Author: Corey Berla <corey berla me>
Date: Mon Jul 25 10:27:08 2022 -0700
view-model: Fix clearing signal handler on sort change
We are attempting to clear the signal after the sorter is already
freed. Clear the signal first.
src/nautilus-view-model.c | 16 +++++++++++-----
1 file changed, 11 insertions(+), 5 deletions(-)
---
diff --git a/src/nautilus-view-model.c b/src/nautilus-view-model.c
index 72fd8a79e..71b838af0 100644
--- a/src/nautilus-view-model.c
+++ b/src/nautilus-view-model.c
@@ -257,7 +257,10 @@ compare_data_func (gconstpointer a,
{
NautilusViewModel *self = NAUTILUS_VIEW_MODEL (user_data);
- g_return_val_if_fail (self->sorter != NULL, GTK_ORDERING_EQUAL);
+ if (self->sorter == NULL)
+ {
+ return GTK_ORDERING_EQUAL;
+ }
return gtk_sorter_compare (self->sorter, (gpointer) a, (gpointer) b);
}
@@ -288,15 +291,18 @@ void
nautilus_view_model_set_sorter (NautilusViewModel *self,
GtkSorter *sorter)
{
+ if (self->sorter != NULL)
+ {
+ g_clear_signal_handler (&self->sorter_changed_id, self->sorter);
+ }
+
if (g_set_object (&self->sorter, sorter))
{
g_object_notify_by_pspec (G_OBJECT (self), properties[PROP_SORTER]);
-
- g_clear_signal_handler (&self->sorter_changed_id, self->sorter);
- self->sorter_changed_id = g_signal_connect (self->sorter, "changed",
- G_CALLBACK (on_sorter_changed), self);
}
+ self->sorter_changed_id = g_signal_connect (self->sorter, "changed",
+ G_CALLBACK (on_sorter_changed), self);
g_list_store_sort (self->internal_model, compare_data_func, self);
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]