mirror of
				https://gitlab.gnome.org/GNOME/glib.git
				synced 2025-10-31 08:22:16 +01:00 
			
		
		
		
	gliststore: Store validity of last_position explicitly
Rather than storing it as an invalid value in last_position, store it as a separate boolean. This introduces no functional changes, but should fix some warnings from MSVC. Signed-off-by: Philip Withnall <withnall@endlessm.com> https://gitlab.gnome.org/GNOME/glib/issues/1500
This commit is contained in:
		| @@ -55,6 +55,7 @@ struct _GListStore | |||||||
|   /* cache */ |   /* cache */ | ||||||
|   guint last_position; |   guint last_position; | ||||||
|   GSequenceIter *last_iter; |   GSequenceIter *last_iter; | ||||||
|  |   gboolean last_position_valid; | ||||||
| }; | }; | ||||||
|  |  | ||||||
| enum | enum | ||||||
| @@ -79,7 +80,8 @@ g_list_store_items_changed (GListStore *store, | |||||||
|   if (position <= store->last_position) |   if (position <= store->last_position) | ||||||
|     { |     { | ||||||
|       store->last_iter = NULL; |       store->last_iter = NULL; | ||||||
|       store->last_position = -1u; |       store->last_position = 0; | ||||||
|  |       store->last_position_valid = FALSE; | ||||||
|     } |     } | ||||||
|  |  | ||||||
|   g_list_model_items_changed (G_LIST_MODEL (store), position, removed, added); |   g_list_model_items_changed (G_LIST_MODEL (store), position, removed, added); | ||||||
| @@ -179,7 +181,7 @@ g_list_store_get_item (GListModel *list, | |||||||
|   GListStore *store = G_LIST_STORE (list); |   GListStore *store = G_LIST_STORE (list); | ||||||
|   GSequenceIter *it = NULL; |   GSequenceIter *it = NULL; | ||||||
|  |  | ||||||
|   if (store->last_position != -1u) |   if (store->last_position_valid) | ||||||
|     { |     { | ||||||
|       if (position < G_MAXUINT && store->last_position == position + 1) |       if (position < G_MAXUINT && store->last_position == position + 1) | ||||||
|         it = g_sequence_iter_prev (store->last_iter); |         it = g_sequence_iter_prev (store->last_iter); | ||||||
| @@ -194,6 +196,7 @@ g_list_store_get_item (GListModel *list, | |||||||
|  |  | ||||||
|   store->last_iter = it; |   store->last_iter = it; | ||||||
|   store->last_position = position; |   store->last_position = position; | ||||||
|  |   store->last_position_valid = TRUE; | ||||||
|  |  | ||||||
|   if (g_sequence_iter_is_end (it)) |   if (g_sequence_iter_is_end (it)) | ||||||
|     return NULL; |     return NULL; | ||||||
| @@ -213,7 +216,8 @@ static void | |||||||
| g_list_store_init (GListStore *store) | g_list_store_init (GListStore *store) | ||||||
| { | { | ||||||
|   store->items = g_sequence_new (g_object_unref); |   store->items = g_sequence_new (g_object_unref); | ||||||
|   store->last_position = -1u; |   store->last_position = 0; | ||||||
|  |   store->last_position_valid = FALSE; | ||||||
| } | } | ||||||
|  |  | ||||||
| /** | /** | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user