[libadwaita/wip/chergert/fix-235: 2/2] tab-view: delay notify::selected-page until after setting
- From: Christian Hergert <chergert src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [libadwaita/wip/chergert/fix-235: 2/2] tab-view: delay notify::selected-page until after setting
- Date: Wed, 21 Jul 2021 21:32:46 +0000 (UTC)
commit a533ca06005e8493c97feb8ef03ee5e57b456e4c
Author: Christian Hergert <chergert redhat com>
Date: Wed Jul 21 14:32:16 2021 -0700
tab-view: delay notify::selected-page until after setting
Currently, notify::selected-page can be emitted before the item is
available in the wrapped GtkSelectionModel as it has not yet been
notified. This causes NULL dereference when used with tooling such as a
GtkListView.
To fix this, we need to set the selection internally, then emit the notify
signal after the wrapped selection model has been updated.
Fixes #235
src/adw-tab-view.c | 6 +++++-
1 file changed, 5 insertions(+), 1 deletion(-)
---
diff --git a/src/adw-tab-view.c b/src/adw-tab-view.c
index e1cce27c..c6ef244e 100644
--- a/src/adw-tab-view.c
+++ b/src/adw-tab-view.c
@@ -931,12 +931,16 @@ insert_page (AdwTabView *self,
attach_page (self, page, position);
+ g_object_freeze_notify (G_OBJECT (self));
+
if (!self->selected_page)
- adw_tab_view_set_selected_page (self, page);
+ set_selected_page (self, page, FALSE);
if (self->pages)
g_list_model_items_changed (G_LIST_MODEL (self->pages), position, 0, 1);
+ g_object_thaw_notify (G_OBJECT (self));
+
return page;
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]