mirror of
https://github.com/gnustep/libs-gui.git
synced 2025-04-23 07:00:46 +00:00
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:
parent
dc754ea0a5
commit
f9ebfcb1cf
3 changed files with 57 additions and 5 deletions
|
@ -130,6 +130,23 @@ static NSMutableDictionary *_modelMap = nil;
|
|||
return [_modelMap objectForKey: type];
|
||||
}
|
||||
|
||||
+ (NSArray *) supportedTypes
|
||||
{
|
||||
NSArray *objectArray = [_modelMap allValues];
|
||||
NSArray *sortedArray = [objectArray sortedArrayUsingSelector:
|
||||
@selector(_comparePriority:)];
|
||||
NSEnumerator *oen = [sortedArray objectEnumerator];
|
||||
Class cls = nil;
|
||||
NSMutableArray *types = [[NSMutableArray alloc] init];
|
||||
|
||||
while ((cls = [oen nextObject]) != nil)
|
||||
{
|
||||
[types addObject: [cls type]];
|
||||
}
|
||||
|
||||
return AUTORELEASE(types);
|
||||
}
|
||||
|
||||
+ (NSString *) supportedModelFileAtPath: (NSString *)modelPath
|
||||
{
|
||||
NSString *result = nil;
|
||||
|
|
|
@ -577,17 +577,24 @@ static NSString *disabledName = @".GNUstepDisabled";
|
|||
{
|
||||
id del = [NSApp delegate];
|
||||
BOOL result = NO;
|
||||
NSError *err = nil;
|
||||
|
||||
if ([del respondsToSelector: _cmd])
|
||||
{
|
||||
result = [del application: theApp openFile: file];
|
||||
}
|
||||
else if ([[NSDocumentController sharedDocumentController]
|
||||
openDocumentWithContentsOfFile: file display: YES] != nil)
|
||||
openDocumentWithContentsOfURL: [NSURL fileURLWithPath: file]
|
||||
display: YES
|
||||
error: &err] != nil)
|
||||
{
|
||||
[NSApp activateIgnoringOtherApps: YES];
|
||||
result = YES;
|
||||
}
|
||||
else
|
||||
{
|
||||
[NSApp presentError: err];
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
|
@ -618,13 +625,16 @@ static NSString *disabledName = @".GNUstepDisabled";
|
|||
{
|
||||
id del = [NSApp delegate];
|
||||
BOOL result = NO;
|
||||
NSError *err = nil;
|
||||
|
||||
if ([del respondsToSelector: _cmd])
|
||||
{
|
||||
result = [del application: theApp openFileWithoutUI: file];
|
||||
}
|
||||
else if ([[NSDocumentController sharedDocumentController]
|
||||
openDocumentWithContentsOfFile: file display: NO] != nil)
|
||||
openDocumentWithContentsOfURL: [NSURL fileURLWithPath: file]
|
||||
display: NO
|
||||
error: &err] != nil)
|
||||
{
|
||||
result = YES;
|
||||
}
|
||||
|
@ -646,13 +656,16 @@ static NSString *disabledName = @".GNUstepDisabled";
|
|||
{
|
||||
id del = [NSApp delegate];
|
||||
BOOL result = NO;
|
||||
NSError *err = nil;
|
||||
|
||||
if ([del respondsToSelector: _cmd])
|
||||
{
|
||||
result = [del application: theApp openURL: aURL];
|
||||
}
|
||||
else if ([[NSDocumentController sharedDocumentController]
|
||||
openDocumentWithContentsOfURL: aURL display: YES] != nil)
|
||||
openDocumentWithContentsOfURL: aURL
|
||||
display: YES
|
||||
error: &err] != nil)
|
||||
{
|
||||
[NSApp activateIgnoringOtherApps: YES];
|
||||
result = YES;
|
||||
|
|
|
@ -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)
|
||||
|
|
Loading…
Reference in a new issue