GSModelLoaderFact, GSServicesManager and GSTextStorage merges

git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/gui/branches/gnustep_testplant_branch@38699 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
Marcian Lytwyn 2015-06-26 16:41:14 +00:00
parent dc754ea0a5
commit f9ebfcb1cf
3 changed files with 57 additions and 5 deletions

View file

@ -57,11 +57,31 @@
#define SANITY_CHECKS 0
static BOOL adding;
/* When caching attributes we make a shallow copy of the dictionary cached,
* so that it is immutable and safe to cache.
* However, we have a potential problem if the objects within the attributes
* dictionary are themselves mutable, and something mutates them while they
* are in the cache. In this case we could items added while different and
* then mutated to have the same contents, so we would not know which of
* the equal dictionaries to remove.
* The solution is to require dictionaries to be identical for removal.
*/
static inline BOOL
cacheEqual(id A, id B)
{
if (YES == adding)
return [A isEqualToDictionary: B];
else
return A == B;
}
#define GSI_MAP_RETAIN_KEY(M, X)
#define GSI_MAP_RELEASE_KEY(M, X)
#define GSI_MAP_RETAIN_VAL(M, X)
#define GSI_MAP_RELEASE_VAL(M, X)
#define GSI_MAP_EQUAL(M, X,Y) [(X).obj isEqualToDictionary: (Y).obj]
#define GSI_MAP_EQUAL(M, X,Y) cacheEqual((X).obj, (Y).obj)
#define GSI_MAP_KTYPES GSUNION_OBJ
#define GSI_MAP_VTYPES GSUNION_NSINT
#define GSI_MAP_NOCLEAN 1
@ -186,6 +206,7 @@ cacheAttributes(NSDictionary *attrs)
GSIMapNode node;
ALOCK();
adding = YES;
node = GSIMapNodeForKey(&attrMap, (GSIMapKey)((id)attrs));
if (node == 0)
{
@ -211,6 +232,7 @@ unCacheAttributes(NSDictionary *attrs)
GSIMapBucket bucket;
ALOCK();
adding = NO;
bucket = GSIMapBucketForKey(&attrMap, (GSIMapKey)((id)attrs));
if (bucket != 0)
{
@ -657,7 +679,7 @@ _attributesAtIndexEffectiveRange(
if (range.length == 0)
{
NSWarnMLog(@"Attempt to set attribute for zero-length range", 0);
NSWarnMLog(@"Attempt to set attribute for zero-length range");
return;
}
if (attributes == nil)