[gnome-software] gs-updates-section: Avoid crash when switching modes
- From: Kalev Lember <klember src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-software] gs-updates-section: Avoid crash when switching modes
- Date: Thu, 17 Oct 2019 08:32:07 +0000 (UTC)
commit 8e2cd118a5dd0efc8553feaf3347ebc25f8545a9
Author: Philip Withnall <withnall endlessm com>
Date: Fri Oct 4 18:20:00 2019 +0100
gs-updates-section: Avoid crash when switching modes
Depending on how the `_list_header_func()` is called for different
orders of rows and updates, it’s possible for the `self->section_header`
to be set as the header for row A. In the next cycle of updates, if it’s
set as the header for row B, and then the header is updated for row A
(to be a normal separator), GTK+ will unparent the
`self->section_header` and leave it parentless.
This causes the following critical:
```
gtk_widget_realize: assertion 'widget->priv->anchored || GTK_IS_INVISIBLE (widget)' failed
**
Gtk:ERROR:../../../../gtk/gtkwidget.c:12348:gtk_widget_real_map: assertion failed:
(_gtk_widget_get_realized (widget))
```
The real fix for this is in GTK+, but in the meantime, we can improve
the situation by using gtk_widget_unparent() (simpler), and only call it
if the row’s header is going to change, rather than unconditionally
unparenting the `self->section_header`.
Signed-off-by: Philip Withnall <withnall endlessm com>
src/gs-updates-section.c | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
---
diff --git a/src/gs-updates-section.c b/src/gs-updates-section.c
index 2743ecc9..c4567b12 100644
--- a/src/gs-updates-section.c
+++ b/src/gs-updates-section.c
@@ -489,9 +489,9 @@ _list_header_func (GtkListBoxRow *row, GtkListBoxRow *before, gpointer user_data
/* section changed */
if (before == NULL) {
- GtkWidget *parent;
- if ((parent = gtk_widget_get_parent (GTK_WIDGET (self->section_header))) != NULL)
- gtk_container_remove (GTK_CONTAINER (parent), GTK_WIDGET (self->section_header));
+ if (gtk_list_box_row_get_header (row) != self->section_header) {
+ gtk_widget_unparent (self->section_header);
+ }
header = self->section_header;
} else {
header = gtk_separator_new (GTK_ORIENTATION_HORIZONTAL);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]