Index: trunk/src/layer.c =================================================================== --- trunk/src/layer.c (revision 14724) +++ trunk/src/layer.c (revision 14725) @@ -724,6 +724,25 @@ return lay; } +unsigned long pcb_layer_hash_bound(pcb_layer_t *ly) +{ + unsigned long hash; + + assert(ly->is_bound); + + hash = (unsigned long)arclist_length(&ly->Arc); + hash ^= (unsigned long)linelist_length(&ly->Line); + hash ^= (unsigned long)textlist_length(&ly->Text); + hash ^= (unsigned long)polylist_length(&ly->Polygon); + hash ^= (unsigned long)ly->comb ^ (unsigned long)ly->meta.bound.type; + + if (ly->meta.bound.type & PCB_LYT_INTERN) + hash ^= ly->meta.bound.stack_offs; + + return hash; +} + + int pcb_layer_type_map(pcb_layer_type_t type, void *ctx, void (*cb)(void *ctx, pcb_layer_type_t bit, const char *name, int class, const char *class_name)) { const pcb_layer_type_name_t *n; Index: trunk/src/layer.h =================================================================== --- trunk/src/layer.h (revision 14724) +++ trunk/src/layer.h (revision 14725) @@ -263,6 +263,10 @@ /* Allocate a new bound layer within data, set it up, but do not do the binding */ pcb_layer_t *pcb_layer_new_bound(pcb_data_t *data, pcb_layer_type_t type, const char *name); +/* Calculate a hash of a bound layer (ingoring its name) */ +unsigned long pcb_layer_hash_bound(pcb_layer_t *ly); + + /* Modify tree pointers in dst to point to src's; allocates trees for src if they are not yet allocated */ void pcb_layer_link_trees(pcb_layer_t *dst, pcb_layer_t *src); Index: trunk/src/obj_subc_hash.c =================================================================== --- trunk/src/obj_subc_hash.c (revision 14724) +++ trunk/src/obj_subc_hash.c (revision 14725) @@ -42,13 +42,15 @@ unsigned int pcb_subc_hash(const pcb_subc_t *sc) { - unsigned int hash = 0; + unsigned int hash; int lid; pcb_host_trans_t tr; pcb_subc_get_host_trans(sc, &tr); - for(lid = 0; lid < sc->data->LayerN; lid++) { + /* hash layers and layer objects */ + hash = sc->data->LayerN; + for(lid = 0; lid 3< sc->data->LayerN; lid++) { pcb_layer_t *ly = &sc->data->Layer[lid]; gdl_iterator_t it; pcb_line_t *l; @@ -56,7 +58,7 @@ pcb_text_t *t; pcb_poly_t *p; -#warning TODO: hash layers + hash ^= pcb_layer_hash_bound(ly); linelist_foreach(&ly->Arc, &it, a) hash ^= pcb_arc_hash(&tr, a); @@ -71,6 +73,8 @@ hash ^= pcb_poly_hash(&tr, p); } + /* hash global objects */ + return hash; }