Fix various compiler warnings with GCC 13

There are various null dereference warnings in GtkListItemManager that
make the build noisy.
This commit is contained in:
Emmanuele Bassi 2023-05-16 18:50:00 +01:00 committed by Matthias Clasen
parent 0434ad3bd9
commit b2a3a5e226

View File

@ -715,6 +715,7 @@ static void
gtk_list_tile_set_type (GtkListTile *tile, gtk_list_tile_set_type (GtkListTile *tile,
GtkListTileType type) GtkListTileType type)
{ {
g_assert (tile != NULL);
if (tile->type == type) if (tile->type == type)
return; return;
@ -845,7 +846,8 @@ gtk_list_item_manager_remove_items (GtkListItemManager *self,
if (offset) if (offset)
tile = gtk_list_item_manager_ensure_split (self, tile, offset); tile = gtk_list_item_manager_ensure_split (self, tile, offset);
header = gtk_list_tile_get_previous_skip (tile); header = gtk_list_tile_get_previous_skip (tile);
if (header->type != GTK_LIST_TILE_HEADER && header->type != GTK_LIST_TILE_UNMATCHED_HEADER) if (header != NULL &&
(header->type != GTK_LIST_TILE_HEADER && header->type != GTK_LIST_TILE_UNMATCHED_HEADER))
header = NULL; header = NULL;
while (n_items > 0) while (n_items > 0)
@ -962,7 +964,7 @@ gtk_list_item_manager_add_items (GtkListItemManager *self,
{ {
GtkListTile *section = gtk_list_tile_get_previous_skip (tile); GtkListTile *section = gtk_list_tile_get_previous_skip (tile);
if (section->type == GTK_LIST_TILE_HEADER) if (section != NULL && section->type == GTK_LIST_TILE_HEADER)
{ {
gtk_list_item_change_clear_header (change, &section->widget); gtk_list_item_change_clear_header (change, &section->widget);
gtk_list_tile_set_type (section, gtk_list_tile_set_type (section,
@ -1225,7 +1227,8 @@ gtk_list_item_manager_insert_section (GtkListItemManager *self,
tile = gtk_list_item_manager_ensure_split (self, tile, offset); tile = gtk_list_item_manager_ensure_split (self, tile, offset);
header = gtk_list_tile_get_previous_skip (tile); header = gtk_list_tile_get_previous_skip (tile);
if (header->type == GTK_LIST_TILE_HEADER || header->type == GTK_LIST_TILE_UNMATCHED_HEADER) if (header != NULL &&
(header->type == GTK_LIST_TILE_HEADER || header->type == GTK_LIST_TILE_UNMATCHED_HEADER))
{ {
if (header_type == GTK_LIST_TILE_HEADER) if (header_type == GTK_LIST_TILE_HEADER)
gtk_list_tile_set_type (header, header_type); gtk_list_tile_set_type (header, header_type);