Author: mlytwyn
Date: Fri Jun 26 18:41:14 2015
New Revision: 38699

URL: http://svn.gna.org/viewcvs/gnustep?rev=38699&view=rev
Log:
GSModelLoaderFact, GSServicesManager and GSTextStorage merges

Modified:
    libs/gui/branches/gnustep_testplant_branch/Source/GSModelLoaderFactory.m
    libs/gui/branches/gnustep_testplant_branch/Source/GSServicesManager.m
    libs/gui/branches/gnustep_testplant_branch/Source/GSTextStorage.m

Modified: 
libs/gui/branches/gnustep_testplant_branch/Source/GSModelLoaderFactory.m
URL: 
http://svn.gna.org/viewcvs/gnustep/libs/gui/branches/gnustep_testplant_branch/Source/GSModelLoaderFactory.m?rev=38699&r1=38698&r2=38699&view=diff
==============================================================================
--- libs/gui/branches/gnustep_testplant_branch/Source/GSModelLoaderFactory.m    
(original)
+++ libs/gui/branches/gnustep_testplant_branch/Source/GSModelLoaderFactory.m    
Fri Jun 26 18:41:14 2015
@@ -128,6 +128,23 @@
 + (Class)classForType: (NSString *)type
 {
   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

Modified: libs/gui/branches/gnustep_testplant_branch/Source/GSServicesManager.m
URL: 
http://svn.gna.org/viewcvs/gnustep/libs/gui/branches/gnustep_testplant_branch/Source/GSServicesManager.m?rev=38699&r1=38698&r2=38699&view=diff
==============================================================================
--- libs/gui/branches/gnustep_testplant_branch/Source/GSServicesManager.m       
(original)
+++ libs/gui/branches/gnustep_testplant_branch/Source/GSServicesManager.m       
Fri Jun 26 18:41:14 2015
@@ -577,16 +577,23 @@
 {
   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 @@
 {
   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 @@
 {
   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;

Modified: libs/gui/branches/gnustep_testplant_branch/Source/GSTextStorage.m
URL: 
http://svn.gna.org/viewcvs/gnustep/libs/gui/branches/gnustep_testplant_branch/Source/GSTextStorage.m?rev=38699&r1=38698&r2=38699&view=diff
==============================================================================
--- libs/gui/branches/gnustep_testplant_branch/Source/GSTextStorage.m   
(original)
+++ libs/gui/branches/gnustep_testplant_branch/Source/GSTextStorage.m   Fri Jun 
26 18:41:14 2015
@@ -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 @@
   GSIMapNode   node;
 
   ALOCK();
+  adding = YES;
   node = GSIMapNodeForKey(&attrMap, (GSIMapKey)((id)attrs));
   if (node == 0)
     {
@@ -211,6 +232,7 @@
   GSIMapBucket       bucket;
 
   ALOCK();
+  adding = NO;
   bucket = GSIMapBucketForKey(&attrMap, (GSIMapKey)((id)attrs));
   if (bucket != 0)
     {
@@ -657,7 +679,7 @@
 
   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)


_______________________________________________
Gnustep-cvs mailing list
[email protected]
https://mail.gna.org/listinfo/gnustep-cvs

Reply via email to