Commit 0d529f79 authored by Martin Nordholts's avatar Martin Nordholts

app: Use GimpIdTable

parent 9fefa22e
......@@ -62,6 +62,7 @@
#include "gimpdocumentlist.h"
#include "gimpgradient-load.h"
#include "gimpgradient.h"
#include "gimpidtable.h"
#include "gimpimage.h"
#include "gimpimagefile.h"
#include "gimplist.h"
......@@ -218,13 +219,11 @@ gimp_init (Gimp *gimp)
gimp->images = gimp_list_new_weak (GIMP_TYPE_IMAGE, FALSE);
gimp_object_set_static_name (GIMP_OBJECT (gimp->images), "images");
gimp->next_image_ID = 1;
gimp->next_guide_ID = 1;
gimp->next_sample_point_ID = 1;
gimp->image_table = g_hash_table_new (g_direct_hash, NULL);
gimp->image_table = gimp_id_table_new ();
gimp->next_item_ID = 1;
gimp->item_table = g_hash_table_new (g_direct_hash, NULL);
gimp->item_table = gimp_id_table_new ();
gimp->displays = g_object_new (GIMP_TYPE_LIST,
"children-type", GIMP_TYPE_OBJECT,
......@@ -417,13 +416,13 @@ gimp_finalize (GObject *object)
if (gimp->item_table)
{
g_hash_table_destroy (gimp->item_table);
g_object_unref (gimp->item_table);
gimp->item_table = NULL;
}
if (gimp->image_table)
{
g_hash_table_destroy (gimp->image_table);
g_object_unref (gimp->image_table);
gimp->image_table = NULL;
}
......@@ -492,8 +491,8 @@ gimp_get_memsize (GimpObject *object,
memsize += gimp_object_get_memsize (GIMP_OBJECT (gimp->plug_in_manager),
gui_size);
memsize += gimp_g_hash_table_get_memsize (gimp->image_table, 0);
memsize += gimp_g_hash_table_get_memsize (gimp->item_table, 0);
memsize += gimp_object_get_memsize (GIMP_OBJECT (gimp->image_table), 0);
memsize += gimp_object_get_memsize (GIMP_OBJECT (gimp->item_table), 0);
memsize += gimp_object_get_memsize (GIMP_OBJECT (gimp->displays), gui_size);
......
......@@ -74,13 +74,11 @@ struct _Gimp
GimpPlugInManager *plug_in_manager;
GimpContainer *images;
gint next_image_ID;
guint32 next_guide_ID;
guint32 next_sample_point_ID;
GHashTable *image_table;
GimpIdTable *image_table;
gint next_item_ID;
GHashTable *item_table;
GimpIdTable *item_table;
GimpContainer *displays;
gint next_display_ID;
......
......@@ -42,6 +42,7 @@
#include "gimpgrid.h"
#include "gimperror.h"
#include "gimpguide.h"
#include "gimpidtable.h"
#include "gimpimage.h"
#include "gimpimage-colorhash.h"
#include "gimpimage-colormap.h"
......@@ -749,19 +750,7 @@ gimp_image_constructed (GObject *object)
config = image->gimp->config;
do
{
private->ID = image->gimp->next_image_ID++;
if (image->gimp->next_image_ID == G_MAXINT)
image->gimp->next_image_ID = 1;
}
while (g_hash_table_lookup (image->gimp->image_table,
GINT_TO_POINTER (private->ID)));
g_hash_table_insert (image->gimp->image_table,
GINT_TO_POINTER (private->ID),
image);
private->ID = gimp_id_table_insert (image->gimp->image_table, image);
template = config->default_image;
......@@ -997,8 +986,7 @@ gimp_image_finalize (GObject *object)
if (image->gimp && image->gimp->image_table)
{
g_hash_table_remove (image->gimp->image_table,
GINT_TO_POINTER (private->ID));
gimp_id_table_remove (image->gimp->image_table, private->ID);
image->gimp = NULL;
}
......@@ -1502,8 +1490,7 @@ gimp_image_get_by_ID (Gimp *gimp,
if (gimp->image_table == NULL)
return NULL;
return (GimpImage *) g_hash_table_lookup (gimp->image_table,
GINT_TO_POINTER (image_id));
return (GimpImage *) gimp_id_table_lookup (gimp->image_table, image_id);
}
void
......
......@@ -30,6 +30,7 @@
#include "gimp.h"
#include "gimp-parasites.h"
#include "gimpchannel.h"
#include "gimpidtable.h"
#include "gimpimage.h"
#include "gimpimage-undo.h"
#include "gimpimage-undo-push.h"
......@@ -337,8 +338,7 @@ gimp_item_finalize (GObject *object)
if (private->image && private->image->gimp)
{
g_hash_table_remove (private->image->gimp->item_table,
GINT_TO_POINTER (private->ID));
gimp_id_table_remove (private->image->gimp->item_table, private->ID);
private->image = NULL;
}
......@@ -1600,8 +1600,7 @@ gimp_item_get_by_ID (Gimp *gimp,
if (gimp->item_table == NULL)
return NULL;
return (GimpItem *) g_hash_table_lookup (gimp->item_table,
GINT_TO_POINTER (item_id));
return (GimpItem *) gimp_id_table_lookup (gimp->item_table, item_id);
}
GimpTattoo
......@@ -1649,19 +1648,7 @@ gimp_item_set_image (GimpItem *item,
if (private->ID == 0)
{
do
{
private->ID = image->gimp->next_item_ID++;
if (image->gimp->next_item_ID == G_MAXINT)
image->gimp->next_item_ID = 1;
}
while (g_hash_table_lookup (image->gimp->item_table,
GINT_TO_POINTER (private->ID)));
g_hash_table_insert (image->gimp->item_table,
GINT_TO_POINTER (private->ID),
item);
private->ID = gimp_id_table_insert (image->gimp->item_table, item);
g_object_notify (G_OBJECT (item), "id");
}
......@@ -1715,13 +1702,13 @@ gimp_item_replace_item (GimpItem *item,
gimp_object_set_name (GIMP_OBJECT (item), gimp_object_get_name (replace));
if (private->ID)
g_hash_table_remove (gimp_item_get_image (item)->gimp->item_table,
GINT_TO_POINTER (gimp_item_get_ID (item)));
gimp_id_table_remove (gimp_item_get_image (item)->gimp->item_table,
gimp_item_get_ID (item));
private->ID = gimp_item_get_ID (replace);
g_hash_table_replace (gimp_item_get_image (item)->gimp->item_table,
GINT_TO_POINTER (gimp_item_get_ID (item)),
item);
gimp_id_table_replace (gimp_item_get_image (item)->gimp->item_table,
gimp_item_get_ID (item),
item);
/* Set image before tatoo so that the explicitly set tatoo overrides
* the one implicitly set when setting the image
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment