sizerequestcache: Make clear_cache clear all the cache

This commit is contained in:
Benjamin Otte 2012-11-13 21:51:29 +01:00
parent 4366f80aab
commit c98ee1ec39
3 changed files with 22 additions and 41 deletions

View File

@ -95,11 +95,9 @@ init_cache (GtkWidget *widget)
cache = _gtk_widget_peek_request_cache (widget);
if (_gtk_widget_get_width_request_needed (widget))
_gtk_size_request_cache_clear (cache, GTK_SIZE_GROUP_HORIZONTAL);
if (_gtk_widget_get_height_request_needed (widget))
_gtk_size_request_cache_clear (cache, GTK_SIZE_GROUP_VERTICAL);
if (_gtk_widget_get_width_request_needed (widget) ||
_gtk_widget_get_height_request_needed (widget))
_gtk_size_request_cache_clear (cache);
return cache;
}

View File

@ -31,46 +31,31 @@ _gtk_size_request_cache_init (SizeRequestCache *cache)
memset (cache, 0, sizeof (SizeRequestCache));
}
static void
free_sizes (SizeRequest **sizes)
{
gint i;
for (i = 0; i < GTK_SIZE_REQUEST_CACHED_SIZES && sizes[i] != NULL; i++)
g_slice_free (SizeRequest, sizes[i]);
g_slice_free1 (sizeof (SizeRequest *) * GTK_SIZE_REQUEST_CACHED_SIZES, sizes);
}
void
_gtk_size_request_cache_free (SizeRequestCache *cache)
{
_gtk_size_request_cache_clear (cache, GTK_SIZE_GROUP_HORIZONTAL);
_gtk_size_request_cache_clear (cache, GTK_SIZE_GROUP_VERTICAL);
if (cache->widths)
free_sizes (cache->widths);
if (cache->heights)
free_sizes (cache->heights);
}
void
_gtk_size_request_cache_clear (SizeRequestCache *cache,
GtkSizeGroupMode orientation)
_gtk_size_request_cache_clear (SizeRequestCache *cache)
{
SizeRequest **sizes;
gint i;
if (orientation == GTK_SIZE_GROUP_HORIZONTAL)
{
sizes = cache->widths;
cache->widths = NULL;
cache->cached_widths = 0;
cache->last_cached_width = 0;
cache->cached_base_width = FALSE;
}
else
{
sizes = cache->heights;
cache->heights = NULL;
cache->cached_heights = 0;
cache->last_cached_height = 0;
cache->cached_base_height = FALSE;
}
if (sizes)
{
for (i = 0; i < GTK_SIZE_REQUEST_CACHED_SIZES && sizes[i] != NULL; i++)
g_slice_free (SizeRequest, sizes[i]);
g_slice_free1 (sizeof (SizeRequest *) * GTK_SIZE_REQUEST_CACHED_SIZES, sizes);
}
_gtk_size_request_cache_free (cache);
_gtk_size_request_cache_init (cache);
}

View File

@ -26,7 +26,6 @@
#define __GTK_SIZE_REQUEST_CACHE_PRIVATE_H__
#include <glib.h>
#include <gtk/gtkenums.h>
G_BEGIN_DECLS
@ -68,8 +67,7 @@ typedef struct {
void _gtk_size_request_cache_init (SizeRequestCache *cache);
void _gtk_size_request_cache_free (SizeRequestCache *cache);
void _gtk_size_request_cache_clear (SizeRequestCache *cache,
GtkSizeGroupMode orientation);
void _gtk_size_request_cache_clear (SizeRequestCache *cache);
G_END_DECLS