Skip to content

Commit

Permalink
Updated with changes from OmniGroup svn [299743:300398]
Browse files Browse the repository at this point in the history
Configurations:
- Updated for apparent renaming of CLANG_ANALYZER_MALLOC -> CLANG_ANALYZER_MEMORY_MANAGEMENT
- Updated for apparent renaming of CLANG_ANALYZER_OBJC_CFNUMBER -> CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION.
- Updates to fix use of NSErrorDomain/NSErrorUserInfoKey/NS_ERROR_ENUM.
- Fix implicit conversion of NSNumber to BOOL.
- Update some targets to Swift 4.
- Nullability and type annotations.
- Layout fixes.

OmniFoundation:
- Fix OFXMLElement's block applier to work correctly on elements with a
  single child.
- Add more Swift wrappers for UTI conveniences.

OmniDataObjects:
- Invalidate computed properties during undo or redo, and suppress
  snapshot-based differences of those same properties. This leaves their values
  nil after an undo/redo change, and the next access will compute
  them correctly.

OmniSoftwareUpdate:
- Updated the OSUInstaller.sh script to specify the path to /usr/bin/id,
  and to ignore any errors from that command (which is just there to
  produce diagnostic output to help us determine why the script might be
  failing in other circumstances).
- When we find a news item is available, attempt to download it and cache
  the html before alerting the user.  When the user requests to see it,
  try first to load it directly from the web, which is the only way we can
  expect a good visual result.  If that fails, show the cached html, which will
  have no CSS and no images but will at least be something and the text should
  be readable.
  Clear the cache after the real page is successfully shown, or before running
  a new OSU check.

OmniAppKit:
- Update an assertion to only assert we have integral-sized images for resources
  from our bundle.
  • Loading branch information
tjw committed Nov 21, 2017
1 parent 4f3ca45 commit bfb611e
Show file tree
Hide file tree
Showing 76 changed files with 752 additions and 484 deletions.
4 changes: 2 additions & 2 deletions Configurations/Omni-Global-Settings.xcconfig
Expand Up @@ -141,13 +141,13 @@ CLANG_ANALYZER_LOCALIZABILITY_NONLOCALIZED = YES
CLANG_ANALYZER_DEADCODE_DEADSTORES = YES
CLANG_ANALYZER_NONNULL = YES
CLANG_ANALYZER_GCD = YES
CLANG_ANALYZER_MALLOC = YES
CLANG_ANALYZER_MEMORY_MANAGEMENT = YES

// Static Analyzer - Checks - Objective-C
CLANG_ANALYZER_OBJC_ATSYNC = YES
CLANG_ANALYZER_OBJC_NSCFERROR = YES
CLANG_ANALYZER_OBJC_INCOMP_METHOD_TYPES = YES
CLANG_ANALYZER_OBJC_CFNUMBER = YES
CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE
CLANG_ANALYZER_OBJC_COLLECTIONS = YES
CLANG_ANALYZER_OBJC_UNUSED_IVARS = YES
CLANG_ANALYZER_OBJC_SELF_INIT = YES
Expand Down
Expand Up @@ -68,8 +68,7 @@ - (id)_initWithContentsOfFile_replacement:(NSString *)fileName;
if (size.width != rint(size.width) || size.height != rint(size.height))
NSLog(@"Image %@ has non-integral size %@", fileName, NSStringFromSize(size));

OBPOSTCONDITION(size.width == rint(size.width));
OBPOSTCONDITION(size.height == rint(size.height));
OBASSERT_IF(OFURLContainsURL([[NSBundle mainBundle] bundleURL], [NSURL fileURLWithPath:fileName]), size.width == rint(size.width) && size.height == rint(size.height), "Our resources should be integral-sized");
return self;
}

Expand Down
Expand Up @@ -166,8 +166,9 @@ + (CGFloat)heightForAttributes:(NSDictionary *)attributes;
}

NSNumber *heightNumber = [HeightForAttributesCache objectForKey:attributes];
if (heightNumber)
if (heightNumber != nil) {
return [heightNumber cgFloatValue];
}

// NOTE: This doesn't account for custom layout done by subclasses
OBASSERT(self == [NSLayoutManager class]);
Expand Down
@@ -1,4 +1,4 @@
// Copyright 1997-2015 Omni Development, Inc. All rights reserved.
// Copyright 1997-2017 Omni Development, Inc. All rights reserved.
//
// This software may only be used and reproduced according to the
// terms in the file OmniSourceLicense.html, which should be
Expand All @@ -10,11 +10,11 @@
#import <AppKit/NSTableView.h>
#import <AppKit/NSNibDeclarations.h>

typedef enum _OATableViewRowVisibility {
typedef NS_ENUM(NSInteger, OATableViewRowVisibility) {
OATableViewRowVisibilityLeaveUnchanged,
OATableViewRowVisibilityScrollToVisible,
OATableViewRowVisibilityScrollToMiddleIfNotVisible
} OATableViewRowVisibility;
};

#import <OmniAppKit/OAFindControllerTargetProtocol.h>

Expand Down
Expand Up @@ -523,7 +523,7 @@ - (CGFloat)size;
}

NSNumber *fontSize = [_attributes objectForKey:(id)kCTFontSizeAttribute];
if (fontSize)
if (fontSize != nil)
return [fontSize cgFloatValue];


Expand Down Expand Up @@ -557,7 +557,7 @@ - (NSInteger)weight;

NSNumber *weightNumber = [self _coreTextFontWeight];

if (weightNumber) {
if (weightNumber != nil) {
CGFloat weight = [weightNumber cgFloatValue];
return _weightToFontManagerWeight(weight);
}
Expand All @@ -584,7 +584,7 @@ static CTFontSymbolicTraits _lookupSymbolicTraits(OAFontDescriptor *self)

NSDictionary *traits = [self->_attributes objectForKey:(id)kCTFontTraitsAttribute];
NSNumber *symbolicTraitsNumber = [traits objectForKey:(id)kCTFontSymbolicTrait];
if (symbolicTraitsNumber) {
if (symbolicTraitsNumber != nil) {
OBASSERT(sizeof(CTFontSymbolicTraits) == sizeof(unsigned int));
CTFontSymbolicTraits result = [symbolicTraitsNumber unsignedIntValue];
return _clearClassMask(result);
Expand Down
@@ -1,4 +1,4 @@
// Copyright 1997-2016 Omni Development, Inc. All rights reserved.
// Copyright 1997-2017 Omni Development, Inc. All rights reserved.
//
// This software may only be used and reproduced according to the
// terms in the file OmniSourceLicense.html, which should be
Expand Down Expand Up @@ -122,7 +122,8 @@ - (OAPreferenceClient *)newClientInstanceInController:(OAPreferenceController *)

// This method was replaced by -willBecomeCurrentPreferenceClient (and the -did variant was added)
OBASSERT_NOT_IMPLEMENTED(clientInstance, becomeCurrentPreferenceClient);


OBASSERT(clientInstance);
return clientInstance;
}

Expand Down
4 changes: 2 additions & 2 deletions Frameworks/OmniAppKit/Widgets.subproj/OASpringLoadHelper.m
@@ -1,4 +1,4 @@
// Copyright 2003-2015 Omni Development, Inc. All rights reserved.
// Copyright 2003-2017 Omni Development, Inc. All rights reserved.
//
// This software may only be used and reproduced according to the
// terms in the file OmniSourceLicense.html, which should be
Expand Down Expand Up @@ -83,7 +83,7 @@ - (void)_startSpringTimer;

// As of 10.5, Finder's spring-loaded folder preference is in the global domain under com.apple.springing.delay, as seconds.
NSNumber *springLoadedFolderDelayNumber = [[NSUserDefaults standardUserDefaults] objectForKey:@"com.apple.springing.delay"];
if (springLoadedFolderDelayNumber) {
if (springLoadedFolderDelayNumber != nil) {
// Might be a different type than we expect; be careful.
if ([springLoadedFolderDelayNumber respondsToSelector:@selector(doubleValue)])
springingDelaySeconds = [springLoadedFolderDelayNumber doubleValue];
Expand Down
1 change: 1 addition & 0 deletions Frameworks/OmniAppKit/Widgets.subproj/OAWebPageViewer.h
Expand Up @@ -30,6 +30,7 @@

- (void)loadPath:(NSString *)path;
- (void)loadRequest:(NSURLRequest *)request;
- (void)loadCachedHTML:(NSURL *)cachedFileURL forWebURL:(NSURL *)webURL; // will use the cached html but still attempt to retrieve relative path linked css and images from the web.

/// on a successful load, success will be true, and error will be nil. If a failure, success will be false and error set. URL is set in all cases and points to the original request's url.
- (void)loadRequest:(NSURLRequest *)request onCompletion:(void (^)(BOOL success, NSURL *url, NSError *error))completionBlock;
Expand Down
18 changes: 18 additions & 0 deletions Frameworks/OmniAppKit/Widgets.subproj/OAWebPageViewer.m
Expand Up @@ -115,6 +115,17 @@ - (void)loadRequest:(NSURLRequest *)request onCompletion:(void (^)(BOOL success,
[self loadRequest:request];
}

- (void)loadCachedHTML:(NSURL *)cachedFileURL forWebURL:(NSURL *)webURL;
{
NSURL *baseURL = [[webURL URLByDeletingLastPathComponent] URLByDeletingLastPathComponent];
NSString *htmlString = [NSString stringWithContentsOfURL:cachedFileURL encoding:kCFStringEncodingUTF8 error:nil];
if (htmlString) {
[[_webView mainFrame] loadHTMLString:htmlString baseURL:baseURL];
} else {
[self loadRequest:[NSURLRequest requestWithURL:webURL]];
}
}

#pragma mark -
#pragma mark Accessors

Expand Down Expand Up @@ -255,6 +266,13 @@ - (void)webView:(WebView *)aWebView decidePolicyForNavigationAction:(NSDictionar
}
}

// Cached news urls are in the user's Library folder
NSURL *userLibrary = [[NSFileManager defaultManager] URLForDirectory:NSLibraryDirectory inDomain:NSUserDomainMask appropriateForURL:nil create:NO error:nil];
if ([[url path] hasPrefix:[userLibrary path]]) {
[listener use];
return;
}

// Initial content
WebNavigationType webNavigationType = [[actionInformation objectForKey:WebActionNavigationTypeKey] intValue];
if (webNavigationType == WebNavigationTypeOther || webNavigationType == WebNavigationTypeReload) {
Expand Down
4 changes: 2 additions & 2 deletions Frameworks/OmniBase/NSError-OBExtensions.m
Expand Up @@ -183,8 +183,8 @@ - (id)initWithPropertyList:(NSDictionary *)propertyList;
NSString *domain = [propertyList objectForKey:@"domain"];
NSNumber *code = [propertyList objectForKey:@"code"];

OBASSERT(domain);
OBASSERT(code);
OBASSERT(domain != nil);
OBASSERT(code != nil);

NSDictionary *userInfo = [propertyList objectForKey:@"userInfo"];
if (userInfo) {
Expand Down
6 changes: 3 additions & 3 deletions Frameworks/OmniBase/NSError-OBUtilities.h
Expand Up @@ -19,10 +19,10 @@ extern "C" {

@class NSString, NSError;

extern NSString * const OBErrorDomain;
extern NSString * const OBFileNameAndNumberErrorKey;
extern NSErrorDomain const OBErrorDomain;
extern NSErrorUserInfoKey const OBFileNameAndNumberErrorKey;

enum {
typedef NS_ERROR_ENUM(OBErrorDomain, OBError) {
OBErrorChained = 1, /* skip code zero since that is often defined to be 'no error' */
};

Expand Down
4 changes: 2 additions & 2 deletions Frameworks/OmniBase/assertions.h
Expand Up @@ -139,13 +139,13 @@ extern void OBLogAssertionFailure(const char *type, const char *expression, cons

// Scalar-taking variants that also do the test at compile time to just signal clang attributes. The input must be a scalar l-value to avoid evaluation of code. This will mark the value as referenced, though, so we don't get unused variable warnings.
#define OBASSERT_NULL(pointer, ...) do { \
if (pointer) { \
if ((pointer) != NULL) { \
void *valuePtr __attribute__((unused)) = &pointer; /* have compiler check that it is an l-value */ \
OBInvokeAssertionFailureHandler("OBASSERT_NULL", #pointer, __FILE__, __LINE__, @"" __VA_ARGS__); \
} \
} while(NO);
#define OBASSERT_NOTNULL(pointer, ...) do { \
if (!pointer) { \
if ((pointer) == NULL) { \
void *valuePtr __attribute__((unused)) = &pointer; /* have compiler check that it is an l-value */ \
OBInvokeAssertionFailureHandler("OBASSERT_NOTNULL", #pointer, __FILE__, __LINE__, @"" __VA_ARGS__); \
} \
Expand Down
2 changes: 1 addition & 1 deletion Frameworks/OmniDataObjects/Errors.h
Expand Up @@ -17,7 +17,7 @@ extern NSErrorUserInfoKey const ODODetailedErrorsKey; // If multiple errors occu

extern NSErrorUserInfoKey const ODODetailedErrorsKey; // if multiple validation errors occur in one operation, they are collected in an array and added with this key to the "top-level error" of the operation

typedef NS_ENUM(NSInteger, ODOError) {
typedef NS_ERROR_ENUM(ODOErrorDomain, ODOError) {
ODONoError = 0,

ODOUnableToLoadModel,
Expand Down
4 changes: 4 additions & 0 deletions Frameworks/OmniDataObjects/ODOObject-Internal.m
Expand Up @@ -482,6 +482,10 @@ _Nullable CFArrayRef ODOObjectCreateDifferenceRecordFromSnapshot(ODOObject *self
continue;
}

if (flags.transient && flags.calculated && ![[entity instanceClass] shouldIncludeSnapshotForTransientCalculatedProperty:prop]) {
continue;
}

id oldValue = (id)CFArrayGetValueAtIndex(snapshot, propertyIndex);
id newValue = _ODOObjectValueAtIndex(self, propertyIndex);

Expand Down
Expand Up @@ -1284,6 +1284,9 @@
DevelopmentTeam = 34YW5XSRB7;
DevelopmentTeamName = "The Omni Group";
};
34B77C0F1EC10F6C00BBBA65 = {
LastSwiftMigration = 0920;
};
8DC2EF4F0486A6940098B216 = {
LastSwiftMigration = 0900;
};
Expand Down Expand Up @@ -1841,7 +1844,7 @@
PRODUCT_BUNDLE_IDENTIFIER = com.omnigroup.framework.OmniDataObjects;
PRODUCT_NAME = OmniDataObjects;
SWIFT_OPTIMIZATION_LEVEL = "-Onone";
SWIFT_VERSION = 3.0;
SWIFT_VERSION = 4.0;
};
name = Debug;
};
Expand All @@ -1857,7 +1860,7 @@
MODULEMAP_FILE = OmniDataObjects.modulemap;
PRODUCT_BUNDLE_IDENTIFIER = com.omnigroup.framework.OmniDataObjects;
PRODUCT_NAME = OmniDataObjects;
SWIFT_VERSION = 3.0;
SWIFT_VERSION = 4.0;
};
name = Release;
};
Expand Down Expand Up @@ -1887,7 +1890,7 @@
PRODUCT_BUNDLE_IDENTIFIER = com.omnigroup.framework.OmniDataObjects;
PRODUCT_NAME = OmniDataObjects;
SWIFT_OPTIMIZATION_LEVEL = "-Onone";
SWIFT_VERSION = 3.0;
SWIFT_VERSION = 4.0;
};
name = Debug;
};
Expand All @@ -1902,7 +1905,7 @@
MODULEMAP_FILE = OmniDataObjects.modulemap;
PRODUCT_BUNDLE_IDENTIFIER = com.omnigroup.framework.OmniDataObjects;
PRODUCT_NAME = OmniDataObjects;
SWIFT_VERSION = 3.0;
SWIFT_VERSION = 4.0;
};
name = Release;
};
Expand Down Expand Up @@ -2022,7 +2025,7 @@
PRODUCT_BUNDLE_IDENTIFIER = com.omnigroup.framework.OmniDataObjects;
PRODUCT_NAME = OmniDataObjects;
SWIFT_OPTIMIZATION_LEVEL = "-Onone";
SWIFT_VERSION = 3.0;
SWIFT_VERSION = 4.0;
};
name = Debug;
};
Expand All @@ -2038,7 +2041,7 @@
MODULEMAP_FILE = OmniDataObjects.modulemap;
PRODUCT_BUNDLE_IDENTIFIER = com.omnigroup.framework.OmniDataObjects;
PRODUCT_NAME = OmniDataObjects;
SWIFT_VERSION = 3.0;
SWIFT_VERSION = 4.0;
};
name = Release;
};
Expand Down
8 changes: 4 additions & 4 deletions Frameworks/OmniDocumentStore/ODSErrors.h
@@ -1,4 +1,4 @@
// Copyright 2010-2013 The Omni Group. All rights reserved.
// Copyright 2010-2017 The Omni Group. All rights reserved.
//
// This software may only be used and reproduced according to the
// terms in the file OmniSourceLicense.html, which should be
Expand All @@ -9,7 +9,9 @@

#import <OmniBase/NSError-OBExtensions.h>

enum {
extern NSErrorDomain const ODSErrorDomain;

typedef NS_ERROR_ENUM(ODSErrorDomain, ODSError) {
// skip zero since it means 'no error' to AppleScript (actually the first 10-ish are defined in NSScriptCommand)
_ODSNoError = 0,

Expand All @@ -18,7 +20,5 @@ enum {

};

extern NSString * const ODSErrorDomain;

#define ODSErrorWithInfo(error, code, description, suggestion, ...) _OBError(error, ODSErrorDomain, code, __FILE__, __LINE__, NSLocalizedDescriptionKey, description, NSLocalizedRecoverySuggestionErrorKey, (suggestion), ## __VA_ARGS__)
#define ODSError(error, code, description, reason) ODSErrorWithInfo((error), (code), (description), (reason), nil)
4 changes: 2 additions & 2 deletions Frameworks/OmniDocumentStore/ODSErrors.m
@@ -1,4 +1,4 @@
// Copyright 2010-2015 Omni Development, Inc. All rights reserved.
// Copyright 2010-2017 Omni Development, Inc. All rights reserved.
//
// This software may only be used and reproduced according to the
// terms in the file OmniSourceLicense.html, which should be
Expand All @@ -9,4 +9,4 @@

RCS_ID("$Id$")

NSString * const ODSErrorDomain = @"com.omnigroup.frameworks.OmniDocumentStore.ErrorDomain";
NSErrorDomain const ODSErrorDomain = @"com.omnigroup.frameworks.OmniDocumentStore.ErrorDomain";
4 changes: 2 additions & 2 deletions Frameworks/OmniDocumentStore/ODSFilter.h
@@ -1,4 +1,4 @@
// Copyright 2010-2015 Omni Development, Inc. All rights reserved.
// Copyright 2010-2017 Omni Development, Inc. All rights reserved.
//
// This software may only be used and reproduced according to the
// terms in the file OmniSourceLicense.html, which should be
Expand All @@ -10,7 +10,7 @@
#import <Foundation/NSObject.h>

@class NSPredicate, NSSet;
@class ODSStore, ODSStore, ODSScope, ODSFolderItem;
@class ODSStore, ODSScope, ODSFolderItem;

@interface ODSFilter : NSObject

Expand Down
22 changes: 6 additions & 16 deletions Frameworks/OmniDocumentStore/ODSFilter.m
Expand Up @@ -18,15 +18,14 @@

@interface ODSFilter ()
@property(nonatomic,copy) NSSet *unfilteredSourceItems;
@property (nonatomic, readwrite) NSSet *filteredItems;
@end

@implementation ODSFilter
{
// The incoming items from the document store
OFSetBinding *_sourceItemsBinding;
NSSet *_sourceItems;

NSPredicate *_filterPredicate;
}

- (instancetype)_initWithBindingSourcePoint:(OFBindingPoint *)sourceBindingPoint;
Expand Down Expand Up @@ -89,27 +88,17 @@ - (void)setFilterPredicate:(NSPredicate *)filterPredicate;

if (filterPredicate == _filterPredicate)
return;

[self willChangeValueForKey:OFValidateKeyPath(self, filteredItems)];

_filterPredicate = filterPredicate;

[self didChangeValueForKey:OFValidateKeyPath(self, filteredItems)];
[self _updateFilteredItems];
}

+ (NSSet *)keyPathsForValuesAffectingFilteredItems;
{
return [NSSet setWithObject:UnfilteredSourceItems];
}

- (NSSet *)filteredItems;
- (void)_updateFilteredItems
{
OBPRECONDITION([NSThread isMainThread]); // We want to fire KVO only on the main thread

if (_filterPredicate)
return [_sourceItems filteredSetUsingPredicate:_filterPredicate];
self.filteredItems = [_sourceItems filteredSetUsingPredicate:_filterPredicate];
else
return _sourceItems;
self.filteredItems = _sourceItems;
}

#pragma mark - Private
Expand All @@ -130,6 +119,7 @@ - (void)setUnfilteredSourceItems:(NSSet *)newItems;
[self willChangeValueForKey:UnfilteredSourceItems];
_sourceItems = [newItems copy];
[self didChangeValueForKey:UnfilteredSourceItems];
[self _updateFilteredItems];
}

@end

0 comments on commit bfb611e

Please sign in to comment.