Commit 3cd810d4 authored by Stephen C. North's avatar Stephen C. North 🙀

Merge branch 'macosx' into 'master'

Fix Mac builds with Xcode 10, and fix warnings (#1445)

See merge request !1302
parents bbb7e222 b7f8eb4d
Pipeline #43001364 passed with stages
in 20 minutes and 16 seconds
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
......@@ -15,7 +15,9 @@
#import <AppKit/AppKit.h>
#import <WebKit/WebKit.h>
@class GVAttributeSchema;
@class GVDocument;
@class GVGraphDefaultAttributes;
@interface GVAttributeInspectorController : NSWindowController {
IBOutlet NSToolbar *componentToolbar;
......@@ -26,8 +28,10 @@
IBOutlet NSTableView *attributeTable;
IBOutlet WebView *documentationWeb;
NSDictionary *_allSchemas;
NSMutableDictionary *_allAttributes;
// 'NSDictionary<NSToolbarItemIdentifier, NSArray<GVAttributeSchema *> *>'
__GENERICS(NSDictionary, NSToolbarItemIdentifier, __GENERICS(NSArray, GVAttributeSchema *) *) *_allSchemas;
// 'NSMutableDictionary<NSToolbarItemIdentifier, GVGraphDefaultAttributes *>'
__GENERICS(NSMutableDictionary, NSToolbarItemIdentifier, GVGraphDefaultAttributes *) *_allAttributes;
GVDocument *_inspectedDocument;
BOOL _otherChangedGraph;
......
......@@ -118,7 +118,7 @@
- (void)tableViewSelectionDidChange:(NSNotification *)aNotification
{
int selectedRow = [[aNotification object] selectedRow];
NSInteger selectedRow = [[aNotification object] selectedRow];
NSString* documentation = selectedRow == -1 ? nil : [[[_allSchemas objectForKey:[componentToolbar selectedItemIdentifier]] objectAtIndex: selectedRow] documentation];
[[documentationWeb mainFrame] loadHTMLString:documentation baseURL:[NSURL URLWithString:@"http://www.graphviz.org/"]];
}
......
......@@ -74,14 +74,14 @@
{
if (!_exporter) {
_exporter = [[GVExportViewController alloc] init];
[_exporter setFilename:[[[self fileURL] path] stringByDeletingPathExtension]];
[_exporter setURL:[[self fileURL] URLByDeletingPathExtension]];
}
[_exporter beginSheetModalForWindow:[self windowForSheet] modalDelegate:self didEndSelector:@selector(exporterDidEnd:)];
}
- (void)exporterDidEnd:(GVExportViewController *)exporter
{
[_graph renderWithFormat:[exporter device] toURL:[NSURL fileURLWithPath:[exporter filename]]];
[_graph renderWithFormat:[exporter device] toURL:[exporter URL]];
}
- (void)fileDidChange:(NSString *)path
......
......@@ -16,14 +16,14 @@
@interface GVExportViewController : NSViewController
{
NSSavePanel *_panel;
NSString *_filename;
NSURL *_url;
NSDictionary *_formatRender;
NSString *_render;
}
@property(readonly) NSArray *formatRenders;
@property(readonly) NSString *device;
@property(retain) NSString *filename;
@property(retain) NSURL *URL;
@property(retain) NSDictionary *formatRender;
@property(retain) NSString *render;
......
......@@ -14,11 +14,11 @@
#import "GVExportViewController.h"
#import "GVGraph.h"
NSMutableArray *_formatRenders = nil;
static NSMutableArray *_formatRenders = nil;
@implementation GVExportViewController
@synthesize filename = _filename;
@synthesize URL = _url;
@synthesize render = _render;
+ (void)initialize
......@@ -51,7 +51,7 @@ NSMutableArray *_formatRenders = nil;
{
if (self = [super initWithNibName:@"Export" bundle:nil]) {
_panel = nil;
_filename = nil;
_url = nil;
_formatRender = nil;
_render = nil;
......@@ -89,7 +89,7 @@ NSMutableArray *_formatRenders = nil;
_formatRender = [formatRender retain];
/* force save panel to use this file type */
[_panel setRequiredFileType:[_formatRender objectForKey:@"format"]];
[_panel setAllowedFileTypes:[NSArray arrayWithObject:[_formatRender objectForKey:@"format"]]];
/* remove existing render if it's not compatible with format */
if (![[_formatRender objectForKey:@"renders"] containsObject:_render])
......@@ -105,42 +105,34 @@ NSMutableArray *_formatRenders = nil;
[endInvocation setSelector:selector];
[endInvocation setArgument:&self atIndex:2];
[endInvocation retain];
_panel = [NSSavePanel savePanel];
[_panel setAccessoryView:[self view]];
[_panel setRequiredFileType:[_formatRender objectForKey:@"format"]];
[_panel
beginSheetForDirectory:[_filename stringByDeletingLastPathComponent]
file:[_filename lastPathComponent]
modalForWindow:window
modalDelegate:self
didEndSelector:@selector(savePanelDidEnd:returnCode:contextInfo:)
contextInfo:endInvocation];
}
[_panel setAllowedFileTypes:[NSArray arrayWithObject:[_formatRender objectForKey:@"format"]]];
[_panel setDirectoryURL:[_url URLByDeletingLastPathComponent]];
[_panel setNameFieldStringValue:[_url lastPathComponent]];
[_panel beginSheetModalForWindow:window completionHandler:^(NSInteger result) {
if (result == NSOKButton) {
NSURL *url = [_panel URL];
if (_url != url) {
[_url release];
_url = [url retain];
}
- (void)savePanelDidEnd:(NSSavePanel *)savePanel returnCode:(int)returnCode contextInfo:(void *)contextInfo
{
NSInvocation *endInvocation = (NSInvocation *)contextInfo;
if (returnCode == NSOKButton) {
NSString *filename = [savePanel filename];
if (_filename != filename) {
[_filename release];
_filename = [filename retain];
/* invoke the end selector on the modal delegate */
[endInvocation invoke];
}
/* invoke the end selector on the modal delegate */
[endInvocation invoke];
}
[endInvocation release];
[_panel setAccessoryView:nil];
_panel = nil;
[endInvocation release];
[_panel setAccessoryView:nil];
_panel = nil;
}];
}
- (void)dealloc
{
[_panel release];
[_filename release];
[_url release];
[_formatRender release];
[_render release];
[super dealloc];
......
......@@ -45,7 +45,7 @@ extern char *gvplugin_list(GVC_t * gvc, api_t api, const char *str);
char *pluginList = gvplugin_list(_graphContext, api, ":");
char *restOfPlugins;
char *nextPlugin;
for (restOfPlugins = pluginList; nextPlugin = strsep(&restOfPlugins, " ");) {
for (restOfPlugins = pluginList; (nextPlugin = strsep(&restOfPlugins, " "));) {
if (*nextPlugin) {
char *lastColon = strrchr(nextPlugin, ':');
if (lastColon) {
......
......@@ -15,7 +15,11 @@
#import <AppKit/AppKit.h>
#import <Quartz/Quartz.h>
@interface GVWindowController : NSWindowController <NSUserInterfaceValidations>
#if !defined(MAC_OS_X_VERSION_10_13) || MAC_OS_X_VERSION_MAX_ALLOWED < MAC_OS_X_VERSION_10_13
@protocol PDFViewDelegate <NSObject> @end
#endif
@interface GVWindowController : NSWindowController <NSUserInterfaceValidations, PDFViewDelegate>
{
IBOutlet PDFView *documentView;
}
......
......@@ -116,14 +116,8 @@
}
- (void)dealloc
{
char darwinStr[256];
size_t size = sizeof(darwinStr);
[[NSNotificationCenter defaultCenter] removeObserver:self name:@"GVGraphDocumentDidChange" object:[self document]];
sysctlbyname("kern.osrelease", darwinStr, &size, NULL, 0);
NSString *darwinVer = [NSString stringWithCString:darwinStr encoding:NSASCIIStringEncoding];
NSString *baseVer = @"11";
if ([darwinVer compare:baseVer] < 0)
[super dealloc];
[super dealloc];
}
......
......@@ -3,7 +3,7 @@
archiveVersion = 1;
classes = {
};
objectVersion = 44;
objectVersion = 46;
objects = {
/* Begin PBXBuildFile section */
......@@ -255,7 +255,7 @@
2A37F4A9FDCFA73011CA2CEA /* Project object */ = {
isa = PBXProject;
buildConfigurationList = C05733CB08A9546B00998B17 /* Build configuration list for PBXProject "graphviz" */;
compatibilityVersion = "Xcode 3.0";
compatibilityVersion = "Xcode 3.2";
developmentRegion = English;
hasScannedForEncodings = 1;
knownRegions = (
......@@ -372,8 +372,6 @@
buildSettings = {
COPY_PHASE_STRIP = NO;
GCC_DYNAMIC_NO_PIC = NO;
GCC_ENABLE_FIX_AND_CONTINUE = YES;
GCC_MODEL_TUNING = G5;
GCC_OPTIMIZATION_LEVEL = 0;
GCC_PRECOMPILE_PREFIX_HEADER = YES;
GCC_PREFIX_HEADER = graphviz_prefix.pch;
......@@ -394,10 +392,8 @@
C05733C908A9546B00998B17 /* Release */ = {
isa = XCBuildConfiguration;
buildSettings = {
ARCHS = "$(ARCHS_STANDARD_32_64_BIT_PRE_XCODE_3_1)";
ARCHS_STANDARD_32_64_BIT_PRE_XCODE_3_1 = "x86_64 i386 ppc";
ARCHS_STANDARD_32_64_BIT_PRE_XCODE_3_1 = x86_64;
DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym";
GCC_MODEL_TUNING = G5;
GCC_PRECOMPILE_PREFIX_HEADER = YES;
GCC_PREFIX_HEADER = graphviz_prefix.pch;
INFOPLIST_FILE = Info.plist;
......@@ -417,24 +413,68 @@
C05733CC08A9546B00998B17 /* Debug */ = {
isa = XCBuildConfiguration;
buildSettings = {
ARCHS = "$(ARCHS_STANDARD_64_BIT)";
CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES;
CLANG_WARN_BOOL_CONVERSION = YES;
CLANG_WARN_COMMA = YES;
CLANG_WARN_CONSTANT_CONVERSION = YES;
CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES;
CLANG_WARN_EMPTY_BODY = YES;
CLANG_WARN_ENUM_CONVERSION = YES;
CLANG_WARN_INFINITE_RECURSION = YES;
CLANG_WARN_INT_CONVERSION = YES;
CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES;
CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES;
CLANG_WARN_OBJC_LITERAL_CONVERSION = YES;
CLANG_WARN_RANGE_LOOP_ANALYSIS = YES;
CLANG_WARN_STRICT_PROTOTYPES = YES;
CLANG_WARN_SUSPICIOUS_MOVE = YES;
CLANG_WARN_UNREACHABLE_CODE = YES;
CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
ENABLE_STRICT_OBJC_MSGSEND = YES;
GCC_NO_COMMON_BLOCKS = YES;
GCC_WARN_64_TO_32_BIT_CONVERSION = YES;
GCC_WARN_ABOUT_RETURN_TYPE = YES;
GCC_WARN_UNDECLARED_SELECTOR = YES;
GCC_WARN_UNINITIALIZED_AUTOS = YES;
GCC_WARN_UNUSED_FUNCTION = YES;
GCC_WARN_UNUSED_VARIABLE = YES;
PREBINDING = NO;
SDKROOT = "$(DEVELOPER_SDK_DIR)/MacOSX10.5.sdk";
MACOSX_DEPLOYMENT_TARGET = 10.6;
SDKROOT = macosx;
};
name = Debug;
};
C05733CD08A9546B00998B17 /* Release */ = {
isa = XCBuildConfiguration;
buildSettings = {
ARCHS = (
ppc,
i386,
);
ARCHS = "$(ARCHS_STANDARD_64_BIT)";
CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES;
CLANG_WARN_BOOL_CONVERSION = YES;
CLANG_WARN_COMMA = YES;
CLANG_WARN_CONSTANT_CONVERSION = YES;
CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES;
CLANG_WARN_EMPTY_BODY = YES;
CLANG_WARN_ENUM_CONVERSION = YES;
CLANG_WARN_INFINITE_RECURSION = YES;
CLANG_WARN_INT_CONVERSION = YES;
CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES;
CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES;
CLANG_WARN_OBJC_LITERAL_CONVERSION = YES;
CLANG_WARN_RANGE_LOOP_ANALYSIS = YES;
CLANG_WARN_STRICT_PROTOTYPES = YES;
CLANG_WARN_SUSPICIOUS_MOVE = YES;
CLANG_WARN_UNREACHABLE_CODE = YES;
CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
ENABLE_STRICT_OBJC_MSGSEND = YES;
GCC_NO_COMMON_BLOCKS = YES;
GCC_WARN_64_TO_32_BIT_CONVERSION = YES;
GCC_WARN_ABOUT_RETURN_TYPE = YES;
GCC_WARN_UNDECLARED_SELECTOR = YES;
GCC_WARN_UNINITIALIZED_AUTOS = YES;
GCC_WARN_UNUSED_FUNCTION = YES;
GCC_WARN_UNUSED_VARIABLE = YES;
PREBINDING = NO;
SDKROOT = "$(DEVELOPER_SDK_DIR)/MacOSX10.5.sdk";
MACOSX_DEPLOYMENT_TARGET = 10.6;
SDKROOT = macosx;
};
name = Release;
};
......
......@@ -15,4 +15,19 @@
#import <Foundation/Foundation.h>
#import <AppKit/AppKit.h>
#import <Quartz/Quartz.h>
#ifndef __has_feature
#define __has_feature(x) 0 // Compatibility with non-clang compilers.
#endif
// Macros to use ObjC generics but keep compatibility with older Xcode versions
// from https://gist.github.com/smileyborg/d513754bc1cf41678054
#if __has_feature(objc_generics)
# define __GENERICS(class, ...) class<__VA_ARGS__>
# define __GENERICS_TYPE(type) type
#else
# define __GENERICS(class, ...) class
# define __GENERICS_TYPE(type) id
#endif
#endif
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment