diff --git a/trunk/AMSProgressBar/AMSProgressBar.xcodeproj/project.pbxproj b/trunk/AMSProgressBar/AMSProgressBar.xcodeproj/project.pbxproj index 21676c4..221ba33 100644 --- a/trunk/AMSProgressBar/AMSProgressBar.xcodeproj/project.pbxproj +++ b/trunk/AMSProgressBar/AMSProgressBar.xcodeproj/project.pbxproj @@ -234,6 +234,7 @@ 2BB596FA09FEFCD00077A885 /* Debug */ = { isa = XCBuildConfiguration; buildSettings = { + CLANG_ENABLE_OBJC_ARC = YES; COPY_PHASE_STRIP = NO; DEPLOYMENT_LOCATION = NO; DSTROOT = ""; @@ -252,7 +253,6 @@ LIBRARY_STYLE = DYNAMIC; MACH_O_TYPE = mh_dylib; MACOSX_DEPLOYMENT_TARGET = 10.11; - "MACOSX_DEPLOYMENT_TARGET[arch=x86_64]" = 10.6; PREBINDING = NO; PRODUCT_NAME = AMSProgressBar; SKIP_INSTALL = YES; @@ -263,6 +263,7 @@ 2BB596FB09FEFCD00077A885 /* Release */ = { isa = XCBuildConfiguration; buildSettings = { + CLANG_ENABLE_OBJC_ARC = YES; COPY_PHASE_STRIP = YES; DYLIB_COMPATIBILITY_VERSION = 1; DYLIB_CURRENT_VERSION = 1; @@ -277,7 +278,6 @@ LIBRARY_STYLE = DYNAMIC; MACH_O_TYPE = mh_dylib; MACOSX_DEPLOYMENT_TARGET = 10.11; - "MACOSX_DEPLOYMENT_TARGET[arch=x86_64]" = 10.6; PREBINDING = NO; PRODUCT_NAME = AMSProgressBar; SKIP_INSTALL = YES; @@ -288,7 +288,7 @@ 2BB596FE09FEFCD00077A885 /* Debug */ = { isa = XCBuildConfiguration; buildSettings = { - MACOSX_DEPLOYMENT_TARGET = 10.6; + MACOSX_DEPLOYMENT_TARGET = 10.11; ONLY_ACTIVE_ARCH = YES; SDKROOT = macosx; }; @@ -297,7 +297,7 @@ 2BB596FF09FEFCD00077A885 /* Release */ = { isa = XCBuildConfiguration; buildSettings = { - MACOSX_DEPLOYMENT_TARGET = 10.6; + MACOSX_DEPLOYMENT_TARGET = 10.11; SDKROOT = macosx; }; name = Release; diff --git a/trunk/AMSProgressBar/AMSProgressPanel.h b/trunk/AMSProgressBar/AMSProgressPanel.h index fcf53ae..ab2ec8c 100644 --- a/trunk/AMSProgressBar/AMSProgressPanel.h +++ b/trunk/AMSProgressBar/AMSProgressPanel.h @@ -12,10 +12,10 @@ @interface AMSProgressPanel : NSObject { - IBOutlet NSWindow *dialogWindow; - IBOutlet NSTextField *explanatoryText; - IBOutlet NSProgressIndicator *progressBar; - IBOutlet NSTextField *timeRemaining; + IBOutlet NSWindow *dialogWindow; + __weak IBOutlet NSTextField *explanatoryText; + __weak IBOutlet NSProgressIndicator *progressBar; + __weak IBOutlet NSTextField *timeRemaining; double progressAmount; //the value of the progress bar. BOOL endsIndeterminate; diff --git a/trunk/AMSProgressBar/AMSProgressPanel.m b/trunk/AMSProgressBar/AMSProgressPanel.m index 55322a3..fe06650 100644 --- a/trunk/AMSProgressBar/AMSProgressPanel.m +++ b/trunk/AMSProgressBar/AMSProgressPanel.m @@ -38,7 +38,7 @@ @implementation AMSProgressPanel //============================================================================== + (AMSProgressPanel *) progressPanel { - AMSProgressPanel *progressWindow = [[[AMSProgressPanel alloc] init] autorelease]; + AMSProgressPanel *progressWindow = [[AMSProgressPanel alloc] init]; return progressWindow; } @@ -54,9 +54,9 @@ + (AMSProgressPanel*) doProgressBarWithMax:(double)maximum forWindow:(NSWindow *)parentWindow message:(NSString*)messageKey { - AMSProgressPanel *progressWindow = [[[AMSProgressPanel alloc] + AMSProgressPanel *progressWindow = [[AMSProgressPanel alloc] initWithMax:maximum - message:messageKey] autorelease]; + message:messageKey]; [progressWindow showAsSheetForWindow:parentWindow]; @@ -93,7 +93,7 @@ - (id) init - (id) initWithMax:(double)maximum message:(NSString*)message { - [self init]; + if (!(self = [self init])) return nil; [progressBar setDoubleValue:0.0]; [progressBar setMaxValue:maximum]; @@ -351,23 +351,4 @@ - (void) close }//end close -#pragma mark - -#pragma mark Destructor -#pragma mark - - -//========== dealloc =========================================================== -//============================================================================== -- (void) dealloc -{ - //Release top-level nib objects - [dialogWindow release]; - - [_startTime release]; - [_previousUpdateTime release]; - - //Finish deallocation - [super dealloc]; -} - - @end diff --git a/trunk/Bricksmith/Bricksmith.xcodeproj/project.pbxproj b/trunk/Bricksmith/Bricksmith.xcodeproj/project.pbxproj index 411e56f..b03fe5e 100644 --- a/trunk/Bricksmith/Bricksmith.xcodeproj/project.pbxproj +++ b/trunk/Bricksmith/Bricksmith.xcodeproj/project.pbxproj @@ -94,7 +94,7 @@ 0B76F2FA0E74CC1700349D03 /* InspectionStep.m in Sources */ = {isa = PBXBuildFile; fileRef = 0B76F2F80E74CC1700349D03 /* InspectionStep.m */; }; 0B83E9B907E3BB0D009C2384 /* LDrawComment.h in Headers */ = {isa = PBXBuildFile; fileRef = 0B83E9B707E3BB0D009C2384 /* LDrawComment.h */; }; 0B83E9BA07E3BB0D009C2384 /* LDrawComment.m in Sources */ = {isa = PBXBuildFile; fileRef = 0B83E9B807E3BB0D009C2384 /* LDrawComment.m */; }; - 0B85168F1400CC34009E3776 /* LDrawGLRenderer.m in Sources */ = {isa = PBXBuildFile; fileRef = 0B3B76AB13DB86AE007CCC5D /* LDrawGLRenderer.m */; }; + 0B85168F1400CC34009E3776 /* LDrawGLRenderer.m in Sources */ = {isa = PBXBuildFile; fileRef = 0B3B76AB13DB86AE007CCC5D /* LDrawGLRenderer.m */; settings = {COMPILER_FLAGS = "-fno-objc-arc"; }; }; 0B8C096810BA532F00BEB111 /* OverlayHelperView.h in Headers */ = {isa = PBXBuildFile; fileRef = 0B8C096610BA532F00BEB111 /* OverlayHelperView.h */; }; 0B8C096910BA532F00BEB111 /* OverlayHelperView.m in Sources */ = {isa = PBXBuildFile; fileRef = 0B8C096710BA532F00BEB111 /* OverlayHelperView.m */; }; 0B8C097310BA550500BEB111 /* OverlayHelperWindow.h in Headers */ = {isa = PBXBuildFile; fileRef = 0B8C097110BA550500BEB111 /* OverlayHelperWindow.h */; }; @@ -216,7 +216,7 @@ 737726E8FC931A7828531671 /* ComputationalGeometry.m in Sources */ = {isa = PBXBuildFile; fileRef = 73772C8BCC3A6435E0AE9103 /* ComputationalGeometry.m */; }; 7377276DD2BFF116BEE36F0A /* libicucore.dylib in Frameworks */ = {isa = PBXBuildFile; fileRef = 73772F01F06AC293E3F650C4 /* libicucore.dylib */; }; 73772B77F842475786994924 /* InspectionLSynth.m in Sources */ = {isa = PBXBuildFile; fileRef = 737728C3A3DF6166BE9183ED /* InspectionLSynth.m */; }; - 73772E2FDEFC3AB2B54D58D3 /* RegexKitLite.m in Sources */ = {isa = PBXBuildFile; fileRef = 737725695C55F263D18C33B9 /* RegexKitLite.m */; }; + 73772E2FDEFC3AB2B54D58D3 /* RegexKitLite.m in Sources */ = {isa = PBXBuildFile; fileRef = 737725695C55F263D18C33B9 /* RegexKitLite.m */; settings = {COMPILER_FLAGS = "-fno-objc-arc"; }; }; 73772F8E91836860E4330407 /* LDrawLSynthDirective.m in Sources */ = {isa = PBXBuildFile; fileRef = 737720E867742FB944EB62C7 /* LDrawLSynthDirective.m */; }; 8D15AC320486D014006FF6A4 /* main.m in Sources */ = {isa = PBXBuildFile; fileRef = 2A37F4B0FDCFA73011CA2CEA /* main.m */; settings = {ATTRIBUTES = (); }; }; 8D15AC340486D014006FF6A4 /* Cocoa.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 1058C7A7FEA54F5311CA2CBB /* Cocoa.framework */; }; @@ -230,6 +230,8 @@ 95D893B916555F3E00AA055B /* LSynthConfiguration.m in Sources */ = {isa = PBXBuildFile; fileRef = 95D893B716555F3E00AA055B /* LSynthConfiguration.m */; }; 95D893CA16569CFD00AA055B /* LDrawLSynth.h in Headers */ = {isa = PBXBuildFile; fileRef = 95D893C816569CFD00AA055B /* LDrawLSynth.h */; }; 95D893CB16569CFD00AA055B /* LDrawLSynth.m in Sources */ = {isa = PBXBuildFile; fileRef = 95D893C916569CFD00AA055B /* LDrawLSynth.m */; }; + 95F759A127BC67AD00CFE5ED /* FastSet.m in Sources */ = {isa = PBXBuildFile; fileRef = 95F7599F27BC67AD00CFE5ED /* FastSet.m */; }; + 95F759A227BC67AD00CFE5ED /* FastSet.h in Headers */ = {isa = PBXBuildFile; fileRef = 95F759A027BC67AD00CFE5ED /* FastSet.h */; }; D608724816ED61F500828B4E /* MeshSmooth.h in Headers */ = {isa = PBXBuildFile; fileRef = D608724616ED61F500828B4E /* MeshSmooth.h */; }; D608724916ED61F500828B4E /* MeshSmooth.c in Sources */ = {isa = PBXBuildFile; fileRef = D608724716ED61F500828B4E /* MeshSmooth.c */; }; D619130117F004A300B5DF44 /* LDrawGLCamera.h in Headers */ = {isa = PBXBuildFile; fileRef = D61912FF17F004A300B5DF44 /* LDrawGLCamera.h */; }; @@ -254,7 +256,6 @@ D6EDBB4816508D7200B4062B /* LDrawBDPAllocator.m in Sources */ = {isa = PBXBuildFile; fileRef = D6EDBB4616508D7200B4062B /* LDrawBDPAllocator.m */; }; D6EDBC251650B9E200B4062B /* LDrawDisplayList.h in Headers */ = {isa = PBXBuildFile; fileRef = D6EDBC231650B9E200B4062B /* LDrawDisplayList.h */; }; D6EDBC261650B9E200B4062B /* LDrawDisplayList.m in Sources */ = {isa = PBXBuildFile; fileRef = D6EDBC241650B9E200B4062B /* LDrawDisplayList.m */; }; - D6FC72131604EBB8005A404E /* LDrawFastSet.h in Headers */ = {isa = PBXBuildFile; fileRef = D6FC72121604EBB8005A404E /* LDrawFastSet.h */; }; /* End PBXBuildFile section */ /* Begin PBXContainerItemProxy section */ @@ -546,6 +547,8 @@ 95D893B716555F3E00AA055B /* LSynthConfiguration.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = LSynthConfiguration.m; sourceTree = ""; }; 95D893C816569CFD00AA055B /* LDrawLSynth.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = LDrawLSynth.h; sourceTree = ""; }; 95D893C916569CFD00AA055B /* LDrawLSynth.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = LDrawLSynth.m; sourceTree = ""; }; + 95F7599F27BC67AD00CFE5ED /* FastSet.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = FastSet.m; sourceTree = ""; }; + 95F759A027BC67AD00CFE5ED /* FastSet.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = FastSet.h; sourceTree = ""; }; D608724616ED61F500828B4E /* MeshSmooth.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MeshSmooth.h; sourceTree = ""; }; D608724716ED61F500828B4E /* MeshSmooth.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = MeshSmooth.c; sourceTree = ""; }; D61912FF17F004A300B5DF44 /* LDrawGLCamera.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = LDrawGLCamera.h; sourceTree = ""; }; @@ -571,7 +574,6 @@ D6EDBB4616508D7200B4062B /* LDrawBDPAllocator.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = LDrawBDPAllocator.m; sourceTree = ""; }; D6EDBC231650B9E200B4062B /* LDrawDisplayList.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = LDrawDisplayList.h; sourceTree = ""; }; D6EDBC241650B9E200B4062B /* LDrawDisplayList.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = LDrawDisplayList.m; sourceTree = ""; }; - D6FC72121604EBB8005A404E /* LDrawFastSet.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = LDrawFastSet.h; sourceTree = ""; }; /* End PBXFileReference section */ /* Begin PBXFrameworksBuildPhase section */ @@ -623,13 +625,14 @@ 0B7588D70D8DC4DD00357703 /* ColorLibrary.m */, 73772E30A6856B15E73A951A /* ComputationalGeometry.h */, 73772C8BCC3A6435E0AE9103 /* ComputationalGeometry.m */, + 95F759A027BC67AD00CFE5ED /* FastSet.h */, + 95F7599F27BC67AD00CFE5ED /* FastSet.m */, D6191B9C17F277B600B5DF44 /* GLMatrixMath.c */, D6191B9B17F277B600B5DF44 /* GLMatrixMath.h */, 0B1DA5A213172DA700E14960 /* LDrawDirective.h */, 0B1DA5A313172DA700E14960 /* LDrawDirective.m */, 0B27CFA81318AA0F005C7E1A /* LDrawDragHandle.h */, 0B27CFA91318AA0F005C7E1A /* LDrawDragHandle.m */, - D6FC72121604EBB8005A404E /* LDrawFastSet.h */, D61912FF17F004A300B5DF44 /* LDrawGLCamera.h */, D619130017F004A300B5DF44 /* LDrawGLCamera.m */, 0B3B76AA13DB86AE007CCC5D /* LDrawGLRenderer.h */, @@ -916,6 +919,7 @@ ); name = "Mac LDraw"; sourceTree = ""; + usesTabs = 1; }; 2A37F4ABFDCFA73011CA2CEA /* Classes */ = { isa = PBXGroup; @@ -1063,6 +1067,7 @@ 0BF729B808AD849300E3DA53 /* DocumentToolbarController.h in Headers */, 0BF729BA08AD849300E3DA53 /* LDrawDocument.h in Headers */, 0BF729BC08AD849300E3DA53 /* LDrawApplication.h in Headers */, + 95F759A227BC67AD00CFE5ED /* FastSet.h in Headers */, 0BF729BE08AD849300E3DA53 /* LDrawColorPanelController.h in Headers */, 0BF729C008AD849300E3DA53 /* PartBrowserDataSource.h in Headers */, 0BF729C608AD849300E3DA53 /* PreferencesDialogController.h in Headers */, @@ -1140,7 +1145,6 @@ 0B6122ED153516600085F944 /* LDrawTexture.h in Headers */, D6EC01BE15A54B3B0004CEB8 /* OpenGLUtilities.h in Headers */, D6CB41E015E2AA6C00730E2A /* ModelManager.h in Headers */, - D6FC72131604EBB8005A404E /* LDrawFastSet.h in Headers */, 95D893B816555F3E00AA055B /* LSynthConfiguration.h in Headers */, 95D893CA16569CFD00AA055B /* LDrawLSynth.h in Headers */, D6EDB983164DEB0000B4062B /* LDrawRenderer.h in Headers */, @@ -1293,6 +1297,7 @@ files = ( 8D15AC320486D014006FF6A4 /* main.m in Sources */, 0B6F384007C81FEF007B1075 /* LDrawFile.m in Sources */, + 95F759A127BC67AD00CFE5ED /* FastSet.m in Sources */, 0B6F384407C82025007B1075 /* LDrawMPDModel.m in Sources */, 0B6F384807C8207B007B1075 /* LDrawModel.m in Sources */, 0B6F3A8F07C9934E007B1075 /* LDrawStep.m in Sources */, @@ -1654,7 +1659,8 @@ isa = XCBuildConfiguration; buildSettings = { ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; - CODE_SIGN_IDENTITY = ""; + CLANG_ENABLE_OBJC_ARC = YES; + CODE_SIGN_IDENTITY = "-"; COPY_PHASE_STRIP = NO; FRAMEWORK_SEARCH_PATHS = ( "\"$(SRCROOT)/../ThirdParty\"", @@ -1673,6 +1679,7 @@ INSTALL_PATH = "$(HOME)/Applications"; LD_RUNPATH_SEARCH_PATHS = "@loader_path/../Frameworks"; MACOSX_DEPLOYMENT_TARGET = 10.11; + OTHER_CODE_SIGN_FLAGS = "--deep"; OTHER_LDFLAGS = ( "-weak_framework", 3DconnexionClient, @@ -1690,7 +1697,8 @@ isa = XCBuildConfiguration; buildSettings = { ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; - CODE_SIGN_IDENTITY = ""; + CLANG_ENABLE_OBJC_ARC = YES; + CODE_SIGN_IDENTITY = "-"; COPY_PHASE_STRIP = YES; FRAMEWORK_SEARCH_PATHS = ( "\"$(SRCROOT)/../ThirdParty\"", @@ -1707,6 +1715,7 @@ INSTALL_PATH = "$(HOME)/Applications"; LD_RUNPATH_SEARCH_PATHS = "@loader_path/../Frameworks"; MACOSX_DEPLOYMENT_TARGET = 10.11; + OTHER_CODE_SIGN_FLAGS = "--deep"; OTHER_LDFLAGS = ( "-weak_framework", 3DconnexionClient, diff --git a/trunk/Bricksmith/Resources/Interface/English.lproj/Donation.xib b/trunk/Bricksmith/Resources/Interface/English.lproj/Donation.xib index 56c5b62..62fda32 100644 --- a/trunk/Bricksmith/Resources/Interface/English.lproj/Donation.xib +++ b/trunk/Bricksmith/Resources/Interface/English.lproj/Donation.xib @@ -77,13 +77,18 @@ DQ - + + + + + + - + diff --git a/trunk/Bricksmith/Resources/Interface/English.lproj/LDrawDocument.xib b/trunk/Bricksmith/Resources/Interface/English.lproj/LDrawDocument.xib index f34422c..232091d 100644 --- a/trunk/Bricksmith/Resources/Interface/English.lproj/LDrawDocument.xib +++ b/trunk/Bricksmith/Resources/Interface/English.lproj/LDrawDocument.xib @@ -436,9 +436,14 @@ - + + + + + + diff --git a/trunk/Bricksmith/Resources/Interface/English.lproj/MinifigureGenerator.xib b/trunk/Bricksmith/Resources/Interface/English.lproj/MinifigureGenerator.xib index afadb32..edabb43 100644 --- a/trunk/Bricksmith/Resources/Interface/English.lproj/MinifigureGenerator.xib +++ b/trunk/Bricksmith/Resources/Interface/English.lproj/MinifigureGenerator.xib @@ -1457,9 +1457,14 @@ Gw - + + + + + + - + + + + + + diff --git a/trunk/Bricksmith/Source/Application/Document/DimensionsPanel.h b/trunk/Bricksmith/Source/Application/Document/DimensionsPanel.h index a57dafe..289a5a2 100644 --- a/trunk/Bricksmith/Source/Application/Document/DimensionsPanel.h +++ b/trunk/Bricksmith/Source/Application/Document/DimensionsPanel.h @@ -19,7 +19,7 @@ LDrawFile *file; LDrawMPDModel *activeModel; - IBOutlet NSTableView *dimensionsTable; + __weak IBOutlet NSTableView *dimensionsTable; } //Initialization diff --git a/trunk/Bricksmith/Source/Application/Document/DimensionsPanel.m b/trunk/Bricksmith/Source/Application/Document/DimensionsPanel.m index 63470ee..973897f 100644 --- a/trunk/Bricksmith/Source/Application/Document/DimensionsPanel.m +++ b/trunk/Bricksmith/Source/Application/Document/DimensionsPanel.m @@ -45,7 +45,7 @@ + (DimensionsPanel *) dimensionPanelForFile:(LDrawFile *)fileIn dimensions = [[DimensionsPanel alloc] initWithFile:fileIn]; - return [dimensions autorelease]; + return dimensions; }//end dimensionPanelForFile: @@ -123,8 +123,6 @@ - (NSString *) panelNibName //============================================================================== - (void) setActiveModel:(LDrawMPDModel *)newModel { - [newModel retain]; - [self->activeModel release]; self->activeModel = newModel; [dimensionsTable reloadData]; @@ -139,9 +137,6 @@ - (void) setActiveModel:(LDrawMPDModel *)newModel //============================================================================== - (void) setFile:(LDrawFile *)newFile { - [newFile retain]; - [self->file release]; - file = newFile; [self setActiveModel:[newFile activeModel]]; @@ -198,8 +193,8 @@ - (id) tableView:(NSTableView *)tableView objectValueForTableColumn:(NSTableColumn *)tableColumn row:(NSInteger)rowIndex { - NSNumberFormatter* floatFormatter = [[NSNumberFormatter new] autorelease]; - NSNumberFormatter* studFormatter = [[NSNumberFormatter new] autorelease]; + NSNumberFormatter* floatFormatter = [NSNumberFormatter new]; + NSNumberFormatter* studFormatter = [NSNumberFormatter new]; id object = nil; Box3 bounds = [self->activeModel boundingBox3]; double width = 0; @@ -304,23 +299,4 @@ - (id) tableView:(NSTableView *)tableView }//end tableView:objectValueForTableColumn:row: -#pragma mark - -#pragma mark DESTRUCTOR -#pragma mark - - -//========== dealloc =========================================================== -// -// Purpose: The end is nigh. -// -//============================================================================== -- (void) dealloc -{ - [file release]; - [activeModel release]; - - [super dealloc]; - -}//end dealloc - - @end diff --git a/trunk/Bricksmith/Source/Application/Document/DocumentToolbarController.h b/trunk/Bricksmith/Source/Application/Document/DocumentToolbarController.h index 26aa043..9a16e08 100644 --- a/trunk/Bricksmith/Source/Application/Document/DocumentToolbarController.h +++ b/trunk/Bricksmith/Source/Application/Document/DocumentToolbarController.h @@ -39,7 +39,7 @@ //////////////////////////////////////////////////////////////////////////////// @interface DocumentToolbarController : NSObject { - IBOutlet LDrawDocument *document; //link to the documnt to which this is attached. + __weak IBOutlet LDrawDocument *document; //link to the documnt to which this is attached. IBOutlet NSView *nudgeXToolView; IBOutlet NSView *nudgeYToolView; diff --git a/trunk/Bricksmith/Source/Application/Document/DocumentToolbarController.m b/trunk/Bricksmith/Source/Application/Document/DocumentToolbarController.m index f44a5d1..e23b1a9 100644 --- a/trunk/Bricksmith/Source/Application/Document/DocumentToolbarController.m +++ b/trunk/Bricksmith/Source/Application/Document/DocumentToolbarController.m @@ -29,18 +29,6 @@ @implementation DocumentToolbarController //============================================================================== - (void) awakeFromNib { - // Retain all our custom views for toolbar items. Why? Because all of these - // could be inserted into the toolbar's view hierarchy, thereby *removing* - // them from their current superview, which holds the ONLY retain on them! - // The result is that without retains here, all these views would be - // deallocated once added then removed from the toolbar! - [gridSegmentedControl retain]; - [orientationSegmentedControl retain]; - [nudgeXToolView retain]; - [nudgeYToolView retain]; - [nudgeZToolView retain]; - [zoomToolView retain]; - [gridSegmentedControl removeFromSuperview]; [orientationSegmentedControl removeFromSuperview]; [nudgeXToolView removeFromSuperview]; @@ -128,7 +116,7 @@ - (NSToolbarItem *)toolbar:(NSToolbar *)toolbar itemForItemIdentifier:(NSString *)itemIdentifier willBeInsertedIntoToolbar:(BOOL)flag { - NSToolbarItem *newItem = [[[NSToolbarItem alloc] initWithItemIdentifier:itemIdentifier] autorelease]; + NSToolbarItem *newItem = [[NSToolbarItem alloc] initWithItemIdentifier:itemIdentifier]; if([itemIdentifier isEqualToString:TOOLBAR_NUDGE_X_IDENTIFIER]) { @@ -264,7 +252,7 @@ - (NSToolbarItem *) makeGridSpacingItem [newItem setLabel:NSLocalizedString(@"GridSpacing",nil)]; [newItem setPaletteLabel:NSLocalizedString(@"GridSpacing",nil)]; - return [newItem autorelease]; + return newItem; }//end makeGridSpacingItem @@ -287,7 +275,7 @@ - (NSToolbarItem *) makeGridOrientationItem [newItem setLabel:NSLocalizedString(@"GridOrientation",nil)]; [newItem setPaletteLabel:NSLocalizedString(@"GridOrientation",nil)]; - return [newItem autorelease]; + return newItem; }//end makeGridOrientationItem @@ -310,7 +298,7 @@ - (NSToolbarItem *) makePartBrowserItem [newItem setTarget:nil]; [newItem setAction:@selector(doPartBrowser:)]; - return [newItem autorelease]; + return newItem; }//end makePartBrowserItem @@ -333,7 +321,7 @@ - (NSToolbarItem *) makeRotationPlusXItem [newItem setAction:@selector(quickRotateClicked:)]; [newItem setTag:rotatePositiveXTag]; - return [newItem autorelease]; + return newItem; }//end makeRotationPlusXItem @@ -356,7 +344,7 @@ - (NSToolbarItem *) makeRotationMinusXItem [newItem setAction:@selector(quickRotateClicked:)]; [newItem setTag:rotateNegativeXTag]; - return [newItem autorelease]; + return newItem; }//end makeRotationMinusXItem @@ -379,7 +367,7 @@ - (NSToolbarItem *) makeRotationPlusYItem [newItem setAction:@selector(quickRotateClicked:)]; [newItem setTag:rotatePositiveYTag]; - return [newItem autorelease]; + return newItem; }//end makeRotationPlusYItem @@ -402,7 +390,7 @@ - (NSToolbarItem *) makeRotationMinusYItem [newItem setAction:@selector(quickRotateClicked:)]; [newItem setTag:rotateNegativeYTag]; - return [newItem autorelease]; + return newItem; }//end makeRotationMinusYItem @@ -425,7 +413,7 @@ - (NSToolbarItem *) makeRotationPlusZItem [newItem setAction:@selector(quickRotateClicked:)]; [newItem setTag:rotatePositiveZTag]; - return [newItem autorelease]; + return newItem; }//end makeRotationPlusZItem @@ -448,7 +436,7 @@ - (NSToolbarItem *) makeRotationMinusZItem [newItem setAction:@selector(quickRotateClicked:)]; [newItem setTag:rotateNegativeZTag]; - return [newItem autorelease]; + return newItem; }//end makeRotationMinusZItem @@ -471,7 +459,7 @@ - (NSToolbarItem *) makeShowColorsItem [newItem setTarget:nil]; [newItem setAction:@selector(showColors:)]; - return [newItem autorelease]; + return newItem; }//end makeShowColorsItem @@ -494,7 +482,7 @@ - (NSToolbarItem *) makeShowInspectorItem [newItem setTarget:nil]; [newItem setAction:@selector(showInspector:)]; - return [newItem autorelease]; + return newItem; }//end makeShowInspectorItem @@ -516,7 +504,7 @@ - (NSToolbarItem *) makeSnapToGridItem [newItem setTarget:self->document]; [newItem setAction:@selector(snapSelectionToGrid:)]; - return [newItem autorelease]; + return newItem; }//end makeSnapToGridItem @@ -540,7 +528,7 @@ - (NSToolbarItem *) makeZoomInItem [newItem setTarget:self->document]; [newItem setAction:@selector(zoomIn:)]; - return [newItem autorelease]; + return newItem; }//end makeZoomInItem @@ -564,7 +552,7 @@ - (NSToolbarItem *) makeZoomOutItem [newItem setTarget:self->document]; [newItem setAction:@selector(zoomOut:)]; - return [newItem autorelease]; + return newItem; }//end makeZoomOutItem @@ -588,7 +576,7 @@ - (NSToolbarItem *) makeZoomItem [newItem setView:zoomToolView]; [newItem setMinSize:[zoomToolView frame].size]; - return [newItem autorelease]; + return newItem; }//end makeZoomItem @@ -766,29 +754,4 @@ - (BOOL) validateToolbarItem:(NSToolbarItem *)item }//end validateToolbarItem: -#pragma mark - -#pragma mark DESTRUCTOR -#pragma mark - - -//========== dealloc =========================================================== -// -// Purpose: My heart will go on... -// -// Note: We DO NOT RELEASE TOP-LEVEL NIB OBJECTS HERE! NSWindowController -// (which comes with our NSDocument) does that automagically. -// -//============================================================================== -- (void) dealloc -{ - [gridSegmentedControl release]; - [nudgeXToolView release]; - [nudgeYToolView release]; - [nudgeZToolView release]; - [zoomToolView release]; - - [super dealloc]; - -}//end dealloc - - @end diff --git a/trunk/Bricksmith/Source/Application/Document/LDrawDocument.h b/trunk/Bricksmith/Source/Application/Document/LDrawDocument.h index ad985c1..99faa2d 100644 --- a/trunk/Bricksmith/Source/Application/Document/LDrawDocument.h +++ b/trunk/Bricksmith/Source/Application/Document/LDrawDocument.h @@ -46,34 +46,34 @@ //////////////////////////////////////////////////////////////////////////////// @interface LDrawDocument : NSDocument { - IBOutlet DocumentToolbarController *toolbarController; - IBOutlet NSObjectController *bindingsController; + __weak IBOutlet DocumentToolbarController *toolbarController; + __weak IBOutlet NSObjectController *bindingsController; // Window satellites - IBOutlet NSDrawer *partBrowserDrawer; - IBOutlet PartBrowserDataSource *partsBrowser; + __weak IBOutlet NSDrawer *partBrowserDrawer; + __weak IBOutlet PartBrowserDataSource *partsBrowser; // Scope bar - IBOutlet NSButton *viewAllButton; - IBOutlet NSButton *viewStepsButton; - IBOutlet NSPopUpButton *submodelPopUpMenu; - IBOutlet NSView *scopeStepControlsContainer; - IBOutlet NSTextField *stepField; - IBOutlet NSSegmentedControl *stepNavigator; + __weak IBOutlet NSButton *viewAllButton; + __weak IBOutlet NSButton *viewStepsButton; + __weak IBOutlet NSPopUpButton *submodelPopUpMenu; + __weak IBOutlet NSView *scopeStepControlsContainer; + __weak IBOutlet NSTextField *stepField; + __weak IBOutlet NSSegmentedControl *stepNavigator; // Window contents - IBOutlet ExtendedSplitView *fileContentsSplitView; - IBOutlet LDrawFileOutlineView *fileContentsOutline; - IBOutlet NSPopUpButton *addReferenceButton; + __weak IBOutlet ExtendedSplitView *fileContentsSplitView; + __weak IBOutlet LDrawFileOutlineView *fileContentsOutline; + __weak IBOutlet NSPopUpButton *addReferenceButton; // LDraw graphic view - IBOutlet ViewportArranger *viewportArranger; - IBOutlet NSTextField *coordinateLabelX; - IBOutlet NSTextField *coordinateLabelY; - IBOutlet NSTextField *coordinateLabelZ; - IBOutlet NSTextField *coordinateFieldX; - IBOutlet NSTextField *coordinateFieldY; - IBOutlet NSTextField *coordinateFieldZ; + __weak IBOutlet ViewportArranger *viewportArranger; + __weak IBOutlet NSTextField *coordinateLabelX; + __weak IBOutlet NSTextField *coordinateLabelY; + __weak IBOutlet NSTextField *coordinateLabelZ; + __weak IBOutlet NSTextField *coordinateFieldX; + __weak IBOutlet NSTextField *coordinateFieldY; + __weak IBOutlet NSTextField *coordinateFieldZ; @private LDrawFile *documentContents; diff --git a/trunk/Bricksmith/Source/Application/Document/LDrawDocument.m b/trunk/Bricksmith/Source/Application/Document/LDrawDocument.m index 32d9937..0cf36ce 100644 --- a/trunk/Bricksmith/Source/Application/Document/LDrawDocument.m +++ b/trunk/Bricksmith/Source/Application/Document/LDrawDocument.m @@ -100,10 +100,10 @@ void AppendChoicesToNewItem( if(menu_style != rpm_merged) { - my_item = [[[NSMenuItem alloc] initWithTitle:child_name action:NULL keyEquivalent:@""] autorelease]; + my_item = [[NSMenuItem alloc] initWithTitle:child_name action:NULL keyEquivalent:@""]; [parent_menu addItem:my_item]; - choices_menu = [[[NSMenu alloc] initWithTitle:@"choices"] autorelease]; + choices_menu = [[NSMenu alloc] initWithTitle:@"choices"]; [my_item setSubmenu:choices_menu]; } else @@ -121,7 +121,7 @@ void AppendChoicesToNewItem( case rpm_merged: title = [NSString stringWithFormat:@"%s: %s", [[ps role] UTF8String], [[ps childName] UTF8String]]; break; } - NSMenuItem * ps_item = [[[NSMenuItem alloc] initWithTitle:title action:@selector(addRelatedPartClicked:) keyEquivalent:@""] autorelease]; + NSMenuItem * ps_item = [[NSMenuItem alloc] initWithTitle:title action:@selector(addRelatedPartClicked:) keyEquivalent:@""]; [choices_menu addItem:ps_item]; [ps_item setRepresentedObject:ps]; } @@ -190,7 +190,7 @@ - (void) windowControllerDidLoadNib:(NSWindowController *) aController [super windowControllerDidLoadNib:aController]; // Create the toolbar. - toolbar = [[[NSToolbar alloc] initWithIdentifier:@"LDrawDocumentToolbar"] autorelease]; + toolbar = [[NSToolbar alloc] initWithIdentifier:@"LDrawDocumentToolbar"]; [toolbar setAutosavesConfiguration:YES]; [toolbar setAllowsUserCustomization:YES]; [toolbar setDelegate:self->toolbarController]; @@ -322,15 +322,6 @@ - (void) windowControllerDidLoadNib:(NSWindowController *) aController name:LDrawPartLibraryReloaded object:nil]; - - //---------- Cleanup for legacy systems ------------------------------------ - // Ewww! - - // (none currently necessary!) - - // Release memory - [coordinateFormatter release]; - }//end windowControllerDidLoadNib: @@ -714,10 +705,7 @@ - (void) setCurrentStep:(NSInteger)requestedStepIndex //============================================================================== - (void) setDocumentContents:(LDrawFile *)newContents { - [newContents retain]; - [documentContents release]; - - // This is going to be an editable container now, so we need to know when it + // This is going to be an editable container now, so we need to know when it // changes. [newContents setPostsNotifications:YES]; @@ -776,9 +764,6 @@ - (void) setGridOrientationMode:(gridOrientationModeT)newMode //============================================================================== - (void) setLastSelectedPart:(LDrawPart *)newPart { - [newPart retain]; - [lastSelectedPart release]; - lastSelectedPart = newPart; }//end setLastSelectedPart: @@ -1451,8 +1436,6 @@ - (void) doMissingPiecesCheck:(id)sender [alert addButtonWithTitle:NSLocalizedString(@"OKButtonName", nil)]; [alert runModal]; - - [alert release]; } }//end doMissingPiecesCheck: @@ -1494,8 +1477,6 @@ - (void) doMovedPiecesCheck:(id)sender //mark document as modified. [self updateChangeCount:NSChangeDone]; } - - [alert release]; } }//end doMovedPiecesCheck: @@ -1595,7 +1576,7 @@ - (IBAction) exportSteps:(id)sender { // Do the save - NSFileManager *fileManager = [[[NSFileManager alloc] init] autorelease]; + NSFileManager *fileManager = [[NSFileManager alloc] init]; NSURL *saveURL = nil; NSString *saveName = nil; NSString *modelName = nil; @@ -1631,11 +1612,9 @@ - (IBAction) exportSteps:(id)sender //Move the target model to the top of the file. That way L3P will know to // render it! LDrawMPDModel *currentModel = [[fileCopy submodels] objectAtIndex:modelCounter]; - [currentModel retain]; [fileCopy removeDirective:currentModel]; [fileCopy insertDirective:currentModel atIndex:0]; [fileCopy setActiveModel:currentModel]; - [currentModel release]; //Make a new folder for the model's steps. modelName = [NSString stringWithFormat:modelnameFormat, [currentModel modelName]]; @@ -1663,9 +1642,6 @@ - (IBAction) exportSteps:(id)sender [currentModel removeDirectiveAtIndex:counter]; } - - [fileCopy release]; - } } @@ -1951,7 +1927,7 @@ - (IBAction) splitModel:(id)sender Matrix4 local = [part transformationMatrix]; Matrix4 global = Matrix4Multiply(local, xfrm); - LDrawPart *newPart = [[[LDrawPart alloc] init] autorelease]; + LDrawPart *newPart = [[LDrawPart alloc] init]; [newPart setLDrawColor:[part LDrawColor]]; [newPart setDisplayName:[part displayName]]; [newPart setTransformationMatrix:&global]; @@ -2735,7 +2711,7 @@ - (IBAction) addModelFromSelectionClicked:(id)sender // Add one new part that refers to the new sub-model. LDrawColor *selectedColor = [[LDrawColorPanelController sharedColorPanel] LDrawColor]; - LDrawPart *newPart = [[[LDrawPart alloc] init] autorelease]; + LDrawPart *newPart = [[LDrawPart alloc] init]; [newPart setLDrawColor:selectedColor]; [newPart setDisplayName:[newModel modelName]]; [newPart setTransformationMatrix:&anchorMatrix]; @@ -2841,7 +2817,6 @@ - (void) addSubmodelReferenceClicked:(id)sender NSBeep(); [alert beginSheetModalForWindow:[self windowForSheet] completionHandler:nil]; - [alert release]; } }//end addSubmodelReferenceClicked: @@ -2853,7 +2828,7 @@ - (void) addSubmodelReferenceClicked:(id)sender //============================================================================== - (IBAction) addLineClicked:(id)sender { - LDrawLine *newLine = [[[LDrawLine alloc] init] autorelease]; + LDrawLine *newLine = [[LDrawLine alloc] init]; NSUndoManager *undoManager = [self undoManager]; LDrawColor *selectedColor = [[LDrawColorPanelController sharedColorPanel] LDrawColor]; Point3 position = ZeroPoint3; @@ -2882,7 +2857,7 @@ - (IBAction) addLineClicked:(id)sender //============================================================================== - (IBAction) addTriangleClicked:(id)sender { - LDrawTriangle *newTriangle = [[[LDrawTriangle alloc] init] autorelease]; + LDrawTriangle *newTriangle = [[LDrawTriangle alloc] init]; NSUndoManager *undoManager = [self undoManager]; LDrawColor *selectedColor = [[LDrawColorPanelController sharedColorPanel] LDrawColor]; Point3 position = ZeroPoint3; @@ -2913,7 +2888,7 @@ - (IBAction) addTriangleClicked:(id)sender //============================================================================== - (IBAction) addQuadrilateralClicked:(id)sender { - LDrawQuadrilateral *newQuadrilateral = [[[LDrawQuadrilateral alloc] init] autorelease]; + LDrawQuadrilateral *newQuadrilateral = [[LDrawQuadrilateral alloc] init]; NSUndoManager *undoManager = [self undoManager]; LDrawColor *selectedColor = [[LDrawColorPanelController sharedColorPanel] LDrawColor]; Point3 position = ZeroPoint3; @@ -2945,7 +2920,7 @@ - (IBAction) addQuadrilateralClicked:(id)sender //============================================================================== - (IBAction) addConditionalClicked:(id)sender { - LDrawConditionalLine *newConditional = [[[LDrawConditionalLine alloc] init] autorelease]; + LDrawConditionalLine *newConditional = [[LDrawConditionalLine alloc] init]; NSUndoManager *undoManager = [self undoManager]; LDrawColor *selectedColor = [[LDrawColorPanelController sharedColorPanel] LDrawColor]; @@ -2966,7 +2941,7 @@ - (IBAction) addConditionalClicked:(id)sender //============================================================================== - (IBAction) addCommentClicked:(id)sender { - LDrawComment *newComment = [[[LDrawComment alloc] init] autorelease]; + LDrawComment *newComment = [[LDrawComment alloc] init]; NSUndoManager *undoManager = [self undoManager]; [self addStepComponent:newComment parent:nil index:NSNotFound]; @@ -2983,7 +2958,7 @@ - (IBAction) addCommentClicked:(id)sender //============================================================================== - (IBAction) addRawCommandClicked:(id)sender { - LDrawMetaCommand *newCommand = [[[LDrawMetaCommand alloc] init] autorelease]; + LDrawMetaCommand *newCommand = [[LDrawMetaCommand alloc] init]; NSUndoManager *undoManager = [self undoManager]; [self addStepComponent:newCommand parent:nil index:NSNotFound]; @@ -3031,7 +3006,7 @@ - (IBAction) addRelatedPartClicked:(id)sender if([parentPart isKindOfClass:[LDrawPart class]]) { // Create our new part to match the parent. - newPart = [[[LDrawPart alloc] init] autorelease]; + newPart = [[LDrawPart alloc] init]; [newPart setLDrawColor:selectedColor]; [newPart setDisplayName:partName]; @@ -3073,8 +3048,6 @@ - (void) addMinifigure:(id)sender [self addModel:minifigure atIndex:NSNotFound preventNameCollisions:YES]; } - [minifigDialog release]; - }//end addMinifigure: @@ -3107,7 +3080,7 @@ - (void) modelSelected:(id)sender //============================================================================== - (void) insertSynthesizableDirective:(id)sender { - LDrawLSynth *synthesizedObject = [[[LDrawLSynth alloc] init] autorelease]; + LDrawLSynth *synthesizedObject = [[LDrawLSynth alloc] init]; NSDictionary *synthEntry = [sender representedObject]; NSString *type = [synthEntry objectForKey:@"LSYNTH_TYPE"]; LDrawColor *selectedColor = [[LDrawColorPanelController sharedColorPanel] LDrawColor]; @@ -3211,7 +3184,6 @@ -(void) insertLSynthConstraint:(id)sender [undoManager setActionName:NSLocalizedString(@"UndoAddLSynthConstraint", nil)]; } - [constraint release]; } } // end insertLSynthConstraint @@ -3286,7 +3258,6 @@ -(void) insertINSIDEOUTSIDELSynthDirective:(id)sender [undoManager setActionName:undoName]; } - [direction release]; } }//end insertINSIDEOUTSIDELSynthDirective: @@ -3909,7 +3880,6 @@ - (BOOL)outlineView:(NSOutlineView *)outlineView //And lastly, select the dragged objects. [(LDrawFileOutlineView*)outlineView selectObjects:pastedObjects]; - [donatingParents release]; return YES; }//end outlineView:acceptDrop:item:childIndex: @@ -3980,8 +3950,7 @@ - (void)outlineViewSelectionDidChange:(NSNotification *)notification [[selectedDirectives objectAtIndex:counter] setSelected:NO]; //Tell the newly-selected directives that they just got selected. - [selectedDirectives release]; - selectedDirectives = [selectedObjects retain]; + selectedDirectives = selectedObjects; for(counter = 0; counter < [self->selectedDirectives count]; counter++) [[selectedDirectives objectAtIndex:counter] setSelected:YES]; @@ -4182,7 +4151,6 @@ - (void) LDrawGLView:(LDrawGLView *)glView dragHandleDidMove:(LDrawDragHandle *) //============================================================================== - (void) LDrawGLViewPartDragEnded:(LDrawGLView*)glView { - [self->selectedDirectivesBeforeCopyDrag release]; self->selectedDirectivesBeforeCopyDrag = nil; } @@ -4205,7 +4173,7 @@ - (void) LDrawGLViewPartDragEnded:(LDrawGLView*)glView //============================================================================== - (void) LDrawGLViewPartsWereDraggedIntoOblivion:(LDrawGLView *)glView { - NSArray *directivesToDelete = [[self->selectedDirectives mutableCopy] autorelease]; + NSArray *directivesToDelete = [self->selectedDirectives mutableCopy]; id currentDirective = nil; for(currentDirective in directivesToDelete) @@ -4258,12 +4226,10 @@ - (void) markPreviousSelection { if(self->markedSelection) { - [self->markedSelection release]; markedSelection = NULL; } markedSelection = [self selectedObjects]; - [markedSelection retain]; }//end markPreviousSelection @@ -4277,7 +4243,6 @@ - (void) unmarkPreviousSelection { if(markedSelection) { - [markedSelection release]; markedSelection = NULL; } }//end unmarkPreviousSelection @@ -5211,7 +5176,7 @@ - (void) addModelsToMenus // // Active Model menu items // - modelItem = [[[NSMenuItem alloc] init] autorelease]; + modelItem = [[NSMenuItem alloc] init]; [modelItem setTitle:modelDescription]; [modelItem setRepresentedObject:currentModel]; [modelItem setTarget:self]; @@ -5220,7 +5185,7 @@ - (void) addModelsToMenus // // MPD reference menu items // - referenceItem = [[[NSMenuItem alloc] init] autorelease]; + referenceItem = [[NSMenuItem alloc] init]; [referenceItem setTitle:modelDescription]; [referenceItem setRepresentedObject:currentModel]; //We set the same tag for all items in the reference menu. @@ -5234,8 +5199,8 @@ - (void) addModelsToMenus // [modelMenu insertItem:modelItem atIndex:separatorIndex+counter+1]; [referenceMenu addItem:referenceItem]; - [[addReferenceButton menu] addItem:[[referenceItem copy] autorelease]]; - [[self->submodelPopUpMenu menu] addItem:[[modelItem copy] autorelease]]; + [[addReferenceButton menu] addItem:[referenceItem copy]]; + [[self->submodelPopUpMenu menu] addItem:[modelItem copy]]; // // Set (or re-set) the selected state @@ -5342,7 +5307,7 @@ - (void) buildRelatedPartsMenus if([kids count]) { - NSMenu * kids_and_roles = [[[NSMenu alloc] initWithTitle:@"Related Parts"] autorelease]; + NSMenu * kids_and_roles = [[NSMenu alloc] initWithTitle:@"Related Parts"]; [relatedItem setSubmenu:kids_and_roles]; [relatedItem setEnabled:TRUE]; @@ -5713,7 +5678,7 @@ - (void) addStep:(LDrawStep *)newStep parent:(LDrawMPDModel*)selectedModel index //============================================================================== - (void) addPartNamed:(NSString *)partName { - LDrawPart *newPart = [[[LDrawPart alloc] init] autorelease]; + LDrawPart *newPart = [[LDrawPart alloc] init]; NSUndoManager *undoManager = [self undoManager]; LDrawColor *selectedColor = [[LDrawColorPanelController sharedColorPanel] LDrawColor]; TransformComponents transformation = IdentityComponents; @@ -5861,9 +5826,6 @@ - (BOOL) canDeleteDirective:(LDrawDirective *)directive [alert beginSheetModalForWindow:[self windowForSheet] completionHandler:nil]; - - [alert release]; - } @@ -5974,10 +5936,7 @@ - (NSAttributedString *) formatDirective:(LDrawDirective *)item initWithString:representation attributes:attributes ]; - //Release stuff we created or copied. - [paragraphStyle release]; - - return [styledString autorelease]; + return styledString; }//end formatDirective:withStringRepresentation: @@ -6427,7 +6386,6 @@ - (void) dealloc if ([NSThread isMainThread]) { [[ModelManager sharedModelManager] documentSignOut:documentContents]; - [documentContents release]; } else { @@ -6440,15 +6398,10 @@ - (void) dealloc LDrawFile * doc = documentContents; dispatch_async(dispatch_get_main_queue(),^{ [[ModelManager sharedModelManager] documentSignOut:doc]; - [doc release]; }); } [[NSNotificationCenter defaultCenter] removeObserver:self]; - [lastSelectedPart release]; - [selectedDirectives release]; - - [super dealloc]; }//end dealloc diff --git a/trunk/Bricksmith/Source/Application/Document/MovePanel.h b/trunk/Bricksmith/Source/Application/Document/MovePanel.h index ef9775e..6605837 100644 --- a/trunk/Bricksmith/Source/Application/Document/MovePanel.h +++ b/trunk/Bricksmith/Source/Application/Document/MovePanel.h @@ -18,7 +18,7 @@ float movementY; float movementZ; - IBOutlet NSFormatter *formatterPoints; + __weak IBOutlet NSFormatter *formatterPoints; } //initialization diff --git a/trunk/Bricksmith/Source/Application/Document/MovePanel.m b/trunk/Bricksmith/Source/Application/Document/MovePanel.m index 06c67ae..df36c70 100644 --- a/trunk/Bricksmith/Source/Application/Document/MovePanel.m +++ b/trunk/Bricksmith/Source/Application/Document/MovePanel.m @@ -80,22 +80,4 @@ - (IBAction) moveButtonClicked:(id)sender }//end moveButtonClicked: -#pragma mark - -#pragma mark DESTRUCTOR -#pragma mark - - -//========== dealloc =========================================================== -// -// Purpose: Moving on to greener pastures. -// -//============================================================================== -- (void) dealloc -{ - [formatterPoints release]; - - [super dealloc]; - -}//end dealloc - - @end diff --git a/trunk/Bricksmith/Source/Application/Document/PieceCountPanel.h b/trunk/Bricksmith/Source/Application/Document/PieceCountPanel.h index f93938e..bc9c8b4 100644 --- a/trunk/Bricksmith/Source/Application/Document/PieceCountPanel.h +++ b/trunk/Bricksmith/Source/Application/Document/PieceCountPanel.h @@ -17,10 +17,10 @@ @interface PieceCountPanel : DialogPanel { - LDrawFile *file; - LDrawMPDModel *activeModel; - PartReport *partReport; - NSMutableArray *flattenedReport; + __weak LDrawFile *file; + __weak LDrawMPDModel *activeModel; + PartReport *partReport; + NSMutableArray *flattenedReport; } //Initialization diff --git a/trunk/Bricksmith/Source/Application/Document/PieceCountPanel.m b/trunk/Bricksmith/Source/Application/Document/PieceCountPanel.m index 866201d..bb6597a 100644 --- a/trunk/Bricksmith/Source/Application/Document/PieceCountPanel.m +++ b/trunk/Bricksmith/Source/Application/Document/PieceCountPanel.m @@ -23,8 +23,8 @@ @interface PieceCountPanel () -@property (nonatomic, strong) IBOutlet NSTableView *pieceCountTable; -@property (nonatomic, strong) IBOutlet LDrawViewerContainer *partPreview; +@property (nonatomic, weak) IBOutlet NSTableView *pieceCountTable; +@property (nonatomic, weak) IBOutlet LDrawViewerContainer *partPreview; @end @@ -38,7 +38,7 @@ @implementation PieceCountPanel //============================================================================== - (void) awakeFromNib { - LDrawColorCell *colorCell = [[[LDrawColorCell alloc] init] autorelease]; + LDrawColorCell *colorCell = [[LDrawColorCell alloc] init]; NSTableColumn *colorColumn = [_pieceCountTable tableColumnWithIdentifier:PART_REPORT_LDRAW_COLOR]; [colorColumn setDataCell:colorCell]; @@ -67,7 +67,7 @@ + (PieceCountPanel *) pieceCountPanelForFile:(LDrawFile *)fileIn panel = [[PieceCountPanel alloc] initWithFile:fileIn]; - return [panel autorelease]; + return panel; }//end pieceCountPanelForFile: @@ -161,8 +161,6 @@ - (void) setActiveModel:(LDrawMPDModel *)newModel PartReport *modelReport = nil; //Update the model name. - [newModel retain]; - [self->activeModel release]; self->activeModel = newModel; //Get the report for the new model. @@ -181,9 +179,6 @@ - (void) setActiveModel:(LDrawMPDModel *)newModel //============================================================================== - (void) setFile:(LDrawFile *)newFile { - [newFile retain]; - [self->file release]; - file = newFile; [self setActiveModel:[newFile activeModel]]; @@ -203,8 +198,6 @@ - (void) setPartReport:(PartReport *)newPartReport NSMutableArray *flattened = nil; //Update the part report - [newPartReport retain]; - [self->partReport release]; partReport = newPartReport; //Prepare some new data for the table view: @@ -231,9 +224,6 @@ - (void) setTableDataSource:(NSMutableArray *) newReport [newReport sortUsingDescriptors:[_pieceCountTable sortDescriptors]]; //Swap out the variable - [newReport retain]; - [flattenedReport release]; - flattenedReport = newReport; //Update the table @@ -409,7 +399,7 @@ - (void) syncSelectionAndPartDisplayed partName = [partRecord objectForKey:PART_REPORT_NUMBER_KEY]; partColor = [partRecord objectForKey:PART_REPORT_LDRAW_COLOR]; - newPart = [[[LDrawPart alloc] init] autorelease]; + newPart = [[LDrawPart alloc] init]; // Not this simple anymore. We have to make sure to draw the optimized // vertexes. The easiest way to do that is to create a part referencing @@ -428,25 +418,4 @@ - (void) syncSelectionAndPartDisplayed }//end syncSelectionAndPartDisplayed -#pragma mark - -#pragma mark DESTRUCTOR -#pragma mark - - -//========== dealloc =========================================================== -// -// Purpose: The end is nigh. -// -//============================================================================== -- (void) dealloc -{ - [file release]; - [activeModel release]; - [partReport release]; - [flattenedReport release]; - - [super dealloc]; - -}//end dealloc - - @end diff --git a/trunk/Bricksmith/Source/Application/Document/RotationPanelController.h b/trunk/Bricksmith/Source/Application/Document/RotationPanelController.h index 8a4c9c5..27e4ea8 100644 --- a/trunk/Bricksmith/Source/Application/Document/RotationPanelController.h +++ b/trunk/Bricksmith/Source/Application/Document/RotationPanelController.h @@ -31,7 +31,7 @@ typedef enum { float fixedPointY; float fixedPointZ; - IBOutlet NSObjectController *objectController; + __weak IBOutlet NSObjectController *objectController; } //initialization diff --git a/trunk/Bricksmith/Source/Application/Document/RotationPanelController.m b/trunk/Bricksmith/Source/Application/Document/RotationPanelController.m index d9d414a..9617a15 100644 --- a/trunk/Bricksmith/Source/Application/Document/RotationPanelController.m +++ b/trunk/Bricksmith/Source/Application/Document/RotationPanelController.m @@ -165,7 +165,6 @@ - (void) windowWillClose:(NSNotification *)notification // cycle in order to fully deallocate. [objectController setContent:nil]; - [self autorelease]; sharedRotationPanel = nil; } @@ -186,22 +185,4 @@ - (NSUndoManager *) windowWillReturnUndoManager:(NSWindow *)window } -#pragma mark - -#pragma mark DESTRUCTOR -#pragma mark - - -//========== dealloc =========================================================== -// -// Purpose: For everything there is a season/(turn, turn, turn)/a time for -// every purpose under heaven/(turn, turn, turn)/a time be born, -// a time to DIE!!!/(turn, turn, turn)/... -// -//============================================================================== -- (void) dealloc -{ - [super dealloc]; - -}//end dealloc - - @end diff --git a/trunk/Bricksmith/Source/Application/Document/SearchPanelController.h b/trunk/Bricksmith/Source/Application/Document/SearchPanelController.h index b042f69..5d72320 100644 --- a/trunk/Bricksmith/Source/Application/Document/SearchPanelController.h +++ b/trunk/Bricksmith/Source/Application/Document/SearchPanelController.h @@ -33,14 +33,14 @@ typedef enum { @interface SearchPanelController : NSWindowController { - IBOutlet NSMatrix *scopeMatrix; - IBOutlet NSMatrix *colorMatrix; - IBOutlet LDrawColorWell *colorWell; - IBOutlet NSMatrix *findTypeMatrix; - IBOutlet NSButton *searchInsideLSynthContainers; - IBOutlet NSButton *searchHiddenParts; - IBOutlet NSTextField *partName; - IBOutlet NSTextField *warningText; + __weak IBOutlet NSMatrix *scopeMatrix; + __weak IBOutlet NSMatrix *colorMatrix; + __weak IBOutlet LDrawColorWell *colorWell; + __weak IBOutlet NSMatrix *findTypeMatrix; + __weak IBOutlet NSButton *searchInsideLSynthContainers; + __weak IBOutlet NSButton *searchHiddenParts; + __weak IBOutlet NSTextField *partName; + __weak IBOutlet NSTextField *warningText; } //Initialization diff --git a/trunk/Bricksmith/Source/Application/Document/SearchPanelController.m b/trunk/Bricksmith/Source/Application/Document/SearchPanelController.m index b2e1309..87f6ec0 100644 --- a/trunk/Bricksmith/Source/Application/Document/SearchPanelController.m +++ b/trunk/Bricksmith/Source/Application/Document/SearchPanelController.m @@ -121,8 +121,8 @@ - (IBAction)doSearchAndSelect:(id)sender NSArray *colorFilter = nil; NSArray *partFilter = nil; - NSMutableArray *selectedParts = [[[NSMutableArray alloc] init] autorelease]; - NSMutableArray *searchableObjects = [[[NSMutableArray alloc] init] autorelease]; + NSMutableArray *selectedParts = [[NSMutableArray alloc] init]; + NSMutableArray *searchableObjects = [[NSMutableArray alloc] init]; // First up, adjust the options if there's no selection if ([selectedObjects count] == 0) { @@ -189,7 +189,7 @@ - (IBAction)doSearchAndSelect:(id)sender // Search within the selection, so just take it wholesale else { - searchableObjects = [[selectedObjects mutableCopy] autorelease]; + searchableObjects = [selectedObjects mutableCopy]; } // Color @@ -244,7 +244,7 @@ - (IBAction)doSearchAndSelect:(id)sender // Collect up all potential matches // - NSMutableArray *matchables = [[[NSMutableArray alloc] init] autorelease]; + NSMutableArray *matchables = [[NSMutableArray alloc] init]; for (id searchableObject in searchableObjects) { // Parts if ([searchableObject isKindOfClass:[LDrawPart class]]) { @@ -266,7 +266,7 @@ - (IBAction)doSearchAndSelect:(id)sender // Filter potential matches against our criteria // - NSMutableArray *nonMatchingParts = [[[NSMutableArray alloc] init] autorelease]; + NSMutableArray *nonMatchingParts = [[NSMutableArray alloc] init]; for (id part in matchables) { @@ -345,7 +345,6 @@ - (IBAction)findTypeOptionChanged:(id)sender { //============================================================================== - (void) windowWillClose:(NSNotification *)notification { - [self autorelease]; sharedSearchPanel = nil; } @@ -375,7 +374,7 @@ - (NSUndoManager *) windowWillReturnUndoManager:(NSWindow *)sender //============================================================================== -(NSArray *)partsInContainer:(LDrawContainer *)container { - NSMutableArray *parts = [[[NSMutableArray alloc] init] autorelease]; + NSMutableArray *parts = [[NSMutableArray alloc] init]; for (id directive in [container subdirectives]) { if ([directive isKindOfClass:[LDrawPart class]]) { [parts addObject:directive]; @@ -511,7 +510,7 @@ -(void)draggingExited:(id < NSDraggingInfo >)sender - (BOOL)prepareForDragOperation:(id)sender { NSArray *archivedDirectives = nil; - NSMutableArray *directiveNames = [[[NSMutableArray alloc] init] autorelease]; + NSMutableArray *directiveNames = [[NSMutableArray alloc] init]; NSUInteger directiveCount = 0; NSUInteger counter = 0; id currentObject = nil; @@ -560,19 +559,4 @@ - (BOOL)prepareForDragOperation:(id)sender return YES; } // end prepareForDragOperation: -#pragma mark - -#pragma mark DESTRUCTOR -#pragma mark - - -//========== dealloc =========================================================== -// -// Purpose: We're off to the big Brick in the sky -// -//============================================================================== -- (void) dealloc -{ - [super dealloc]; - -}//end dealloc - @end diff --git a/trunk/Bricksmith/Source/Application/General/DonationDialogController.h b/trunk/Bricksmith/Source/Application/General/DonationDialogController.h index 78fd1a3..dd70e74 100644 --- a/trunk/Bricksmith/Source/Application/General/DonationDialogController.h +++ b/trunk/Bricksmith/Source/Application/General/DonationDialogController.h @@ -19,9 +19,9 @@ //////////////////////////////////////////////////////////////////////////////// @interface DonationDialogController : NSWindowController { - IBOutlet BackgroundColorView *mainBackground; - IBOutlet BackgroundColorView *bottomBar; - IBOutlet NSButton *suppressionCheckbox; + __weak IBOutlet BackgroundColorView *mainBackground; + __weak IBOutlet BackgroundColorView *bottomBar; + __weak IBOutlet NSButton *suppressionCheckbox; } // Show dialog diff --git a/trunk/Bricksmith/Source/Application/General/DonationDialogController.m b/trunk/Bricksmith/Source/Application/General/DonationDialogController.m index d25563d..4159319 100644 --- a/trunk/Bricksmith/Source/Application/General/DonationDialogController.m +++ b/trunk/Bricksmith/Source/Application/General/DonationDialogController.m @@ -19,7 +19,7 @@ @interface DonationDialogController () -@property (nonatomic, strong) IBOutlet LDrawViewerContainer* bumViewer; +@property (nonatomic, weak) IBOutlet LDrawViewerContainer* bumViewer; @end diff --git a/trunk/Bricksmith/Source/Application/General/LDrawApplication.m b/trunk/Bricksmith/Source/Application/General/LDrawApplication.m index 9a7c2c2..5367336 100644 --- a/trunk/Bricksmith/Source/Application/General/LDrawApplication.m +++ b/trunk/Bricksmith/Source/Application/General/LDrawApplication.m @@ -52,7 +52,7 @@ @implementation LDrawApplication //------------------------------------------------------------------------------ + (void) initialize { - TransformerIntMinus1 *minus1Transformer = [[[TransformerIntMinus1 alloc] init] autorelease]; + TransformerIntMinus1 *minus1Transformer = [[TransformerIntMinus1 alloc] init]; [NSValueTransformer setValueTransformer:minus1Transformer forName:@"TransformerIntMinus1" ]; @@ -112,7 +112,7 @@ + (NSOpenGLPixelFormat *) openGLPixelFormat 0}; pixelFormat = [[NSOpenGLPixelFormat alloc] initWithAttributes: pixelAttributes]; - return [pixelFormat autorelease]; + return pixelFormat; } @@ -544,8 +544,6 @@ - (NSApplicationTerminateReply) applicationShouldTerminate:(NSApplication *)send [donation runModal]; } - [donation release]; - return NSTerminateNow; }//end applicationShouldTerminate: @@ -818,7 +816,7 @@ - (void) populateLSynthModelMenus // User has turned off filtering in prefs ![userDefaults boolForKey:LSYNTH_SHOW_BASIC_PARTS_LIST_KEY]) { - NSMenuItem *entryMenuItem = [[[NSMenuItem alloc] init] autorelease]; + NSMenuItem *entryMenuItem = [[NSMenuItem alloc] init]; [entryMenuItem setTitle:[entry objectForKey:[menuSpec objectForKey:@"entry_key"]]]; [entryMenuItem setRepresentedObject:entry]; [entryMenuItem setAction:NSSelectorFromString([menuSpec objectForKey:@"action"])]; @@ -852,21 +850,21 @@ - (void) populateLSynthModelMenus // [invertSelectionItem setTag:lsynthInvertINSIDEOUTSIDETag]; // [insideOutsideMenu addItem:invertSelectionItem]; - NSMenuItem *addInsideItem = [[[NSMenuItem alloc] init] autorelease]; + NSMenuItem *addInsideItem = [[NSMenuItem alloc] init]; [addInsideItem setTitle:@"Insert INSIDE"]; [addInsideItem setTarget:nil]; [addInsideItem setAction:@selector(insertINSIDEOUTSIDELSynthDirective:)]; [addInsideItem setTag:lsynthInsertINSIDETag]; [insideOutsideMenu addItem:addInsideItem]; - NSMenuItem *addOutsideItem = [[[NSMenuItem alloc] init] autorelease]; + NSMenuItem *addOutsideItem = [[NSMenuItem alloc] init]; [addOutsideItem setTitle:@"Insert OUTSIDE"]; [addOutsideItem setTarget:nil]; [addOutsideItem setAction:@selector(insertINSIDEOUTSIDELSynthDirective:)]; [addOutsideItem setTag:lsynthInsertOUTSIDETag]; [insideOutsideMenu addItem:addOutsideItem]; - NSMenuItem *addCrossItem = [[[NSMenuItem alloc] init] autorelease]; + NSMenuItem *addCrossItem = [[NSMenuItem alloc] init]; [addCrossItem setTitle:@"Insert CROSS"]; [addCrossItem setTarget:nil]; [addCrossItem setAction:@selector(insertINSIDEOUTSIDELSynthDirective:)]; @@ -895,26 +893,6 @@ - (NSString *) userName } -#pragma mark - -#pragma mark DESTRUCTOR -#pragma mark - - -//========== dealloc =========================================================== -// -// Purpose: The curtain falls. -// -//============================================================================== -- (void) dealloc -{ - [partLibraryController release]; - [inspector release]; - [sharedGLContext release]; - - [super dealloc]; - -}//end dealloc - - #pragma mark - #pragma mark CALLBACKS #pragma mark - diff --git a/trunk/Bricksmith/Source/Application/General/LDrawColorPanelController.h b/trunk/Bricksmith/Source/Application/General/LDrawColorPanelController.h index 5e9c370..410c881 100644 --- a/trunk/Bricksmith/Source/Application/General/LDrawColorPanelController.h +++ b/trunk/Bricksmith/Source/Application/General/LDrawColorPanelController.h @@ -20,12 +20,12 @@ //////////////////////////////////////////////////////////////////////////////// @interface LDrawColorPanelController : NSWindowController { - IBOutlet LDrawColorBar *colorBar; - IBOutlet NSPopUpButton *materialPopUpButton; - IBOutlet NSTableView *colorTable; - IBOutlet NSSearchField *searchField; + __weak IBOutlet LDrawColorBar *colorBar; + __weak IBOutlet NSPopUpButton *materialPopUpButton; + __weak IBOutlet NSTableView *colorTable; + __weak IBOutlet NSSearchField *searchField; - IBOutlet NSArrayController *colorListController; + __weak IBOutlet NSArrayController *colorListController; //YES if we are in the middle of updating the color panel to // reflect the current selection, NO any other time. diff --git a/trunk/Bricksmith/Source/Application/General/LDrawColorPanelController.m b/trunk/Bricksmith/Source/Application/General/LDrawColorPanelController.m index 993bbb1..f4df59c 100644 --- a/trunk/Bricksmith/Source/Application/General/LDrawColorPanelController.m +++ b/trunk/Bricksmith/Source/Application/General/LDrawColorPanelController.m @@ -51,7 +51,7 @@ @implementation LDrawColorPanelController //============================================================================== - (void) windowDidLoad { - LDrawColorCell *colorCell = [[[LDrawColorCell alloc] init] autorelease]; + LDrawColorCell *colorCell = [[LDrawColorCell alloc] init]; NSTableColumn *colorColumn = [colorTable tableColumnWithIdentifier:@"colorCode"]; [colorColumn setDataCell:colorCell]; @@ -629,10 +629,6 @@ - (void) dealloc { [colorListController removeObserver:self forKeyPath:@"selectedObjects"]; [colorListController removeObserver:self forKeyPath:@"sortDescriptors"]; - - [colorListController release]; - - [super dealloc]; }//end dealloc diff --git a/trunk/Bricksmith/Source/Application/General/MinifigureDialogController.m b/trunk/Bricksmith/Source/Application/General/MinifigureDialogController.m index 841541e..022acd2 100644 --- a/trunk/Bricksmith/Source/Application/General/MinifigureDialogController.m +++ b/trunk/Bricksmith/Source/Application/General/MinifigureDialogController.m @@ -63,7 +63,7 @@ @interface MinifigureDialogController () //top-level objects @property (nonatomic, strong) IBOutlet NSObjectController* objectController; -@property (nonatomic, strong) IBOutlet NSNumberFormatter* degreesFormatter; +@property (nonatomic, weak) IBOutlet NSNumberFormatter* degreesFormatter; @property (nonatomic, strong) IBOutlet NSArrayController* hatsController; @property (nonatomic, strong) IBOutlet NSArrayController* headsController; @property (nonatomic, strong) IBOutlet NSArrayController* necksController; @@ -84,22 +84,22 @@ @interface MinifigureDialogController () // Panel widgets -@property (nonatomic, unsafe_unretained) IBOutlet LDrawViewerContainer* minifigurePreview; -@property (nonatomic, unsafe_unretained) IBOutlet LDrawColorWell* hatsColorWell; -@property (nonatomic, unsafe_unretained) IBOutlet LDrawColorWell* headsColorWell; -@property (nonatomic, unsafe_unretained) IBOutlet LDrawColorWell* necksColorWell; -@property (nonatomic, unsafe_unretained) IBOutlet LDrawColorWell* torsosColorWell; -@property (nonatomic, unsafe_unretained) IBOutlet LDrawColorWell* rightArmsColorWell; -@property (nonatomic, unsafe_unretained) IBOutlet LDrawColorWell* rightHandsColorWell; -@property (nonatomic, unsafe_unretained) IBOutlet LDrawColorWell* rightHandAccessoriesColorWell; -@property (nonatomic, unsafe_unretained) IBOutlet LDrawColorWell* leftArmsColorWell; -@property (nonatomic, unsafe_unretained) IBOutlet LDrawColorWell* leftHandsColorWell; -@property (nonatomic, unsafe_unretained) IBOutlet LDrawColorWell* leftHandAccessoriesColorWell; -@property (nonatomic, unsafe_unretained) IBOutlet LDrawColorWell* hipsColorWell; -@property (nonatomic, unsafe_unretained) IBOutlet LDrawColorWell* rightLegsColorWell; -@property (nonatomic, unsafe_unretained) IBOutlet LDrawColorWell* rightLegAccessoriesColorWell; -@property (nonatomic, unsafe_unretained) IBOutlet LDrawColorWell* leftLegsColorWell; -@property (nonatomic, unsafe_unretained) IBOutlet LDrawColorWell* leftLegAccessoriesColorWell; +@property (nonatomic, weak) IBOutlet LDrawViewerContainer* minifigurePreview; +@property (nonatomic, weak) IBOutlet LDrawColorWell* hatsColorWell; +@property (nonatomic, weak) IBOutlet LDrawColorWell* headsColorWell; +@property (nonatomic, weak) IBOutlet LDrawColorWell* necksColorWell; +@property (nonatomic, weak) IBOutlet LDrawColorWell* torsosColorWell; +@property (nonatomic, weak) IBOutlet LDrawColorWell* rightArmsColorWell; +@property (nonatomic, weak) IBOutlet LDrawColorWell* rightHandsColorWell; +@property (nonatomic, weak) IBOutlet LDrawColorWell* rightHandAccessoriesColorWell; +@property (nonatomic, weak) IBOutlet LDrawColorWell* leftArmsColorWell; +@property (nonatomic, weak) IBOutlet LDrawColorWell* leftHandsColorWell; +@property (nonatomic, weak) IBOutlet LDrawColorWell* leftHandAccessoriesColorWell; +@property (nonatomic, weak) IBOutlet LDrawColorWell* hipsColorWell; +@property (nonatomic, weak) IBOutlet LDrawColorWell* rightLegsColorWell; +@property (nonatomic, weak) IBOutlet LDrawColorWell* rightLegAccessoriesColorWell; +@property (nonatomic, weak) IBOutlet LDrawColorWell* leftLegsColorWell; +@property (nonatomic, weak) IBOutlet LDrawColorWell* leftLegAccessoriesColorWell; @end @@ -118,28 +118,6 @@ - (void) awakeFromNib [_minifigurePreview.glView setAutosaveName:@"MinifigureGeneratorView"]; [_minifigurePreview.glView restoreConfiguration]; - // Top-level nib object are never released. We assign them to strong properties, - // so we have to let them go here. - [_objectController autorelease]; - [_degreesFormatter autorelease]; - [_hatsController autorelease]; - [_headsController autorelease]; - [_necksController autorelease]; - [_torsosController autorelease]; - [_rightArmsController autorelease]; - [_rightHandsController autorelease]; - [_rightHandAccessoriesController autorelease]; - [_leftArmsController autorelease]; - [_leftHandsController autorelease]; - [_leftHandAccessoriesController autorelease]; - [_hipsController autorelease]; - [_rightLegsController autorelease]; - [_rightLegAccessoriesController autorelease]; - [_leftLegsController autorelease]; - [_leftLegAccessoriesController autorelease]; - - [_minifigureGeneratorPanel autorelease]; - }//end awakeFromNib @@ -156,7 +134,7 @@ - (id) init { self = [super init]; - iniFile = [[MLCadIni iniFile] retain]; + iniFile = [MLCadIni iniFile]; [self setMinifigureName:NSLocalizedString(@"UntitledMinifigure", nil)]; //we'll call -generateMinifigure: when the dialog is ready and loaded with @@ -193,9 +171,6 @@ - (LDrawMPDModel *) minifigure //============================================================================== - (void) setMinifigure:(LDrawMPDModel *)newMinifigure { - [newMinifigure retain]; - [self->minifigure release]; - self->minifigure = newMinifigure; [_minifigurePreview.glView setLDrawDirective:newMinifigure]; @@ -259,9 +234,6 @@ - (void) setAngleOfLeftLegAccessory:(float)angle {angleOfLeftLegAccessory = angl //============================================================================== - (void) setMinifigureName:(NSString *)newName { - [newName retain]; - [self->minifigureName release]; - minifigureName = newName; [self->minifigure setModelDisplayName:newName]; @@ -348,6 +320,10 @@ - (IBAction) colorWellChanged:(id)sender //============================================================================== - (IBAction) generateMinifigure:(id)sender { + if (_objectController.content == nil) { + return; + } + LDrawMPDModel *newMinifigure = [LDrawMPDModel model]; LDrawStep *firstStep = [[newMinifigure steps] objectAtIndex:0]; @@ -608,24 +584,6 @@ - (IBAction) generateMinifigure:(id)sender //this is it! We've got a minifigure! [self setMinifigure:newMinifigure]; - - - //Free memory - [hat release]; - [head release]; - [neck release]; - [torso release]; - [leftArm release]; - [leftHand release]; - [leftHandAccessory release]; - [rightArm release]; - [rightHand release]; - [rightHandAccessory release]; - [hips release]; - [leftLeg release]; - [leftLegAccessory release]; - [rightLeg release]; - [rightLegAccessory release]; }//end generateMinifigure @@ -955,28 +913,7 @@ - (void) savePartControllerSelection:(NSArrayController *)controller //============================================================================== - (void) dealloc { - [_objectController release]; - [_degreesFormatter release]; - [_hatsController release]; - [_headsController release]; - [_necksController release]; - [_torsosController release]; - [_rightArmsController release]; - [_rightHandsController release]; - [_rightHandAccessoriesController release]; - [_leftArmsController release]; - [_leftHandsController release]; - [_leftHandAccessoriesController release]; - [_hipsController release]; - [_rightLegsController release]; - [_rightLegAccessoriesController release]; - [_leftLegsController release]; - [_leftLegAccessoriesController release]; - [_minifigureGeneratorPanel release]; - - [iniFile release]; - - [super dealloc]; + CFRelease((__bridge CFTypeRef)_minifigureGeneratorPanel); }//end dealloc diff --git a/trunk/Bricksmith/Source/Application/General/PartBrowserDataSource.h b/trunk/Bricksmith/Source/Application/General/PartBrowserDataSource.h index 8d622b9..feca27c 100644 --- a/trunk/Bricksmith/Source/Application/General/PartBrowserDataSource.h +++ b/trunk/Bricksmith/Source/Application/General/PartBrowserDataSource.h @@ -22,25 +22,25 @@ //////////////////////////////////////////////////////////////////////////////// @interface PartBrowserDataSource : NSObject { - IBOutlet NSButton *searchAllCategoriesButton; - IBOutlet NSButton *searchSelectedCategoryButton; - IBOutlet NSSearchField *searchField; + __weak IBOutlet NSButton *searchAllCategoriesButton; + __weak IBOutlet NSButton *searchSelectedCategoryButton; + __weak IBOutlet NSSearchField *searchField; - IBOutlet NSOutlineView *categoryTable; - IBOutlet NSTableView *partsTable; - IBOutlet LDrawGLView *partPreview; - IBOutlet LDrawViewerContainer *partPreviewViewport; - IBOutlet NSButton *zoomInButton; - IBOutlet NSButton *zoomOutButton; - IBOutlet NSButton *addRemoveFavoriteButton; - IBOutlet NSButton *insertButton; - IBOutlet NSMenu *contextualMenu; + __weak IBOutlet NSOutlineView *categoryTable; + __weak IBOutlet NSTableView *partsTable; + __weak IBOutlet LDrawGLView *partPreview; + __weak IBOutlet LDrawViewerContainer *partPreviewViewport; + __weak IBOutlet NSButton *zoomInButton; + __weak IBOutlet NSButton *zoomOutButton; + __weak IBOutlet NSButton *addRemoveFavoriteButton; + __weak IBOutlet NSButton *insertButton; + __weak IBOutlet NSMenu *contextualMenu; - PartLibrary *partLibrary; //weak reference to the shared part catalog. - NSString *selectedCategory; - NSArray *categoryList; - NSMutableArray *tableDataSource; - SearchModeT searchMode; + __weak PartLibrary *partLibrary; //weak reference to the shared part catalog. + __weak NSString *selectedCategory; + __weak NSArray *categoryList; + NSMutableArray *tableDataSource; + SearchModeT searchMode; } diff --git a/trunk/Bricksmith/Source/Application/General/PartBrowserDataSource.m b/trunk/Bricksmith/Source/Application/General/PartBrowserDataSource.m index 0f745a7..4ee54a2 100644 --- a/trunk/Bricksmith/Source/Application/General/PartBrowserDataSource.m +++ b/trunk/Bricksmith/Source/Application/General/PartBrowserDataSource.m @@ -161,12 +161,6 @@ - (void) awakeFromNib selector: @selector(sharedPartCatalogDidChange:) name: LDrawPartLibraryDidChangeNotification object: nil ]; - - - //---------- Free Memory ----------------------------------------------- - [searchMenuTemplate release]; - [recentsItem release]; - [noRecentsItem release]; } // Loading "PartBrowserAccessories.nib" else @@ -189,8 +183,8 @@ - (id) init [NSBundle loadNibNamed:@"PartBrowserAccessories" owner:self]; // Not displaying anything yet. - categoryList = [[NSArray array] retain]; - tableDataSource = [[NSMutableArray array] retain]; + categoryList = [NSArray array]; + tableDataSource = [NSMutableArray array]; searchMode = [[NSUserDefaults standardUserDefaults] integerForKey:PART_BROWSER_SEARCH_MODE]; return self; @@ -256,14 +250,12 @@ - (BOOL) loadCategory:(NSString *)newCategory success = (partsInCategory != nil); // Assign instance variable - [newCategory retain]; - [self->selectedCategory release]; self->selectedCategory = newCategory; if(success == YES) { // Build the (sortable) list of part records. - allPartRecords = [[partsInCategory mutableCopy] autorelease]; + allPartRecords = [partsInCategory mutableCopy]; // Update data [self setTableDataSource:allPartRecords]; @@ -314,9 +306,6 @@ - (void) setPartLibrary:(PartLibrary *)partLibraryIn - (void) setCategoryList:(NSArray *)newCategoryList { //swap the variable - [newCategoryList retain]; - [categoryList release]; - categoryList = newCategoryList; //Update the category chooser @@ -348,9 +337,6 @@ - (void) setTableDataSource:(NSMutableArray *)allPartRecords [allPartRecords sortUsingDescriptors:[partsTable sortDescriptors]]; // Swap out the variable - [allPartRecords retain]; - [self->tableDataSource release]; - self->tableDataSource = allPartRecords; [partsTable reloadData]; @@ -770,7 +756,7 @@ - (void)tableViewSelectionDidChange:(NSNotification *)aNotification - (void) sharedPartCatalogDidChange:(NSNotification *)notification { PartLibrary *newLibrary = [notification object]; - NSString *originalSelectedCategory = [self->selectedCategory retain]; + NSString *originalSelectedCategory = self->selectedCategory; NSString *originalSearch = [self->searchField stringValue]; NSInteger selectedRow = [self->partsTable selectedRow]; @@ -791,8 +777,6 @@ - (void) sharedPartCatalogDidChange:(NSNotification *)notification byExtendingSelection:NO]; [self syncSelectionAndPartDisplayed]; - [originalSelectedCategory release]; - }//end sharedPartCatalogDidChange: @@ -1103,7 +1087,7 @@ - (void) syncSelectionAndPartDisplayed // the model. // modelToView = [self->partLibrary modelForName:selectedPartName]; - newPart = [[[LDrawPart alloc] init] autorelease]; + newPart = [[LDrawPart alloc] init]; //Set up the part attributes [newPart setLDrawColor:[[ColorLibrary sharedColorLibrary] colorForCode:LDrawCurrentColor]]; @@ -1132,7 +1116,7 @@ - (BOOL) writeSelectedPartToPasteboard:(NSPasteboard *)pasteboard //We got a part; let's add it! if(partName != nil) { - newPart = [[[LDrawPart alloc] init] autorelease]; + newPart = [[LDrawPart alloc] init]; //Set up the part attributes [newPart setLDrawColor:selectedColor]; @@ -1173,13 +1157,6 @@ - (void) dealloc //Remove notifications [[NSNotificationCenter defaultCenter] removeObserver:self]; - //Release data - [categoryList release]; - [tableDataSource release]; - [contextualMenu release]; - - [super dealloc]; - }//end dealloc diff --git a/trunk/Bricksmith/Source/Application/General/PartBrowserPanelController.h b/trunk/Bricksmith/Source/Application/General/PartBrowserPanelController.h index 362ecb0..ee71819 100644 --- a/trunk/Bricksmith/Source/Application/General/PartBrowserPanelController.h +++ b/trunk/Bricksmith/Source/Application/General/PartBrowserPanelController.h @@ -14,8 +14,8 @@ @interface PartBrowserPanelController : NSWindowController { - IBOutlet PartBrowserDataSource *partsBrowser; - IBOutlet ExtendedSplitView *splitView; + __weak IBOutlet PartBrowserDataSource *partsBrowser; + __weak IBOutlet ExtendedSplitView *splitView; } //Initialization diff --git a/trunk/Bricksmith/Source/Application/General/PartBrowserPanelController.m b/trunk/Bricksmith/Source/Application/General/PartBrowserPanelController.m index ec8c50f..247fc17 100644 --- a/trunk/Bricksmith/Source/Application/General/PartBrowserPanelController.m +++ b/trunk/Bricksmith/Source/Application/General/PartBrowserPanelController.m @@ -110,7 +110,6 @@ - (void)windowWillClose:(NSNotification *)notification { //Make sure our memory is all released. sharedPartBrowserPanel = nil; - [self autorelease]; }//end windowWillClose: @@ -143,22 +142,4 @@ - (CGFloat)splitView:(NSSplitView *)sender constrainMinCoordinate:(CGFloat)propo }//end splitView:constrainMinCoordinate:ofSubviewAt: -#pragma mark - -#pragma mark DESTRUCTOR -#pragma mark - - -//========== dealloc =========================================================== -// -// Purpose: We're checking out of this fleabag hotel. -// -//============================================================================== -- (void) dealloc -{ - // no need to release top-level nib objects, as this is an NSWindowController - - [super dealloc]; - -}//end dealloc - - @end diff --git a/trunk/Bricksmith/Source/Application/General/PartLibraryController.m b/trunk/Bricksmith/Source/Application/General/PartLibraryController.m index e7b7eed..0056395 100644 --- a/trunk/Bricksmith/Source/Application/General/PartLibraryController.m +++ b/trunk/Bricksmith/Source/Application/General/PartLibraryController.m @@ -80,7 +80,7 @@ - (void) loadPartCatalog:(void (^)(BOOL success))completionHandler //============================================================================== - (void) reloadPartCatalog:(void (^)(BOOL success))completionHandler { - AMSProgressPanel* progressPanel = [[AMSProgressPanel progressPanel] retain]; + AMSProgressPanel* progressPanel = [AMSProgressPanel progressPanel]; [progressPanel setMessage:@"Loading Parts"]; [progressPanel showProgressPanel]; @@ -144,8 +144,6 @@ - (BOOL) validateLDrawFolderWithMessage:(NSString *) folderPath [error setInformativeText:NSLocalizedString(@"LDrawFolderChooserErrorInformative", nil)]; [error runModal]; - - [error release]; } return folderIsValid; @@ -170,20 +168,4 @@ - (void) partLibrary:(PartLibrary *)partLibrary didChangeFavorites:(NSArray *)ne } -#pragma mark - -#pragma mark DESTRUCTOR -#pragma mark - - -//========== dealloc =========================================================== -// -// Purpose: We're, uh, checking out. -// -//============================================================================== -- (void) dealloc -{ - [super dealloc]; - -}//end dealloc - - @end diff --git a/trunk/Bricksmith/Source/Application/General/PreferencesDialogController.h b/trunk/Bricksmith/Source/Application/General/PreferencesDialogController.h index 0e7bddf..0b11ca6 100644 --- a/trunk/Bricksmith/Source/Application/General/PreferencesDialogController.h +++ b/trunk/Bricksmith/Source/Application/General/PreferencesDialogController.h @@ -31,51 +31,51 @@ typedef enum { //////////////////////////////////////////////////////////////////////////////// @interface PreferencesDialogController : NSObject { - IBOutlet NSWindow *preferencesWindow; + IBOutlet NSWindow *preferencesWindow; - NSView *blankContent; //the initial, empty content of the window in the Nib. - IBOutlet NSView *generalTabContentView; - IBOutlet NSView *stylesContentView; - IBOutlet NSView *ldrawContentView; - IBOutlet NSView *lsynthContentView; + __weak NSView *blankContent; //the initial, empty content of the window in the Nib. + __weak IBOutlet NSView *generalTabContentView; + __weak IBOutlet NSView *stylesContentView; + __weak IBOutlet NSView *ldrawContentView; + __weak IBOutlet NSView *lsynthContentView; // General Tab - IBOutlet NSMatrix *mouseDraggingRadioButtons; + __weak IBOutlet NSMatrix *mouseDraggingRadioButtons; - IBOutlet NSMatrix *rotateModeRadioButtons; - IBOutlet NSMatrix *rightButtonRadioButtons; - IBOutlet NSMatrix *mouseWheelRadioButtons; + __weak IBOutlet NSMatrix *rotateModeRadioButtons; + __weak IBOutlet NSMatrix *rightButtonRadioButtons; + __weak IBOutlet NSMatrix *mouseWheelRadioButtons; // Parts Tab - IBOutlet NSTextField *LDrawPathTextField; - IBOutlet NSMatrix *partBrowserStyleRadioButtons; + __weak IBOutlet NSTextField *LDrawPathTextField; + __weak IBOutlet NSMatrix *partBrowserStyleRadioButtons; // Style Tab - IBOutlet NSColorWell *backgroundColorWell; + __weak IBOutlet NSColorWell *backgroundColorWell; - IBOutlet NSColorWell *modelsColorWell; - IBOutlet NSColorWell *stepsColorWell; - IBOutlet NSColorWell *partsColorWell; - IBOutlet NSColorWell *primitivesColorWell; - IBOutlet NSColorWell *colorsColorWell; - IBOutlet NSColorWell *commentsColorWell; - IBOutlet NSColorWell *unknownColorWell; + __weak IBOutlet NSColorWell *modelsColorWell; + __weak IBOutlet NSColorWell *stepsColorWell; + __weak IBOutlet NSColorWell *partsColorWell; + __weak IBOutlet NSColorWell *primitivesColorWell; + __weak IBOutlet NSColorWell *colorsColorWell; + __weak IBOutlet NSColorWell *commentsColorWell; + __weak IBOutlet NSColorWell *unknownColorWell; // LSynth Tab - IBOutlet NSTextField *lsynthExecutablePath; - IBOutlet NSTextField *lsynthConfigurationPath; - IBOutlet NSMatrix *lsynthSelectionModeMatrix; - IBOutlet NSSlider *lsynthTransparencySlider; - IBOutlet NSTextField *lsynthTransparencyText; - IBOutlet NSColorWell *lsynthSelectionColorWell; - IBOutlet NSButton *lsynthSaveSynthesizedParts; - IBOutlet NSView *lsynthExecutableChooserAccessoryView; - IBOutlet NSView *lsynthConfigurationChooserAccessoryView; - NSTextField *lsynthTransparencyNumberChanged; - IBOutlet NSButton *lsynthShowBasicPartsList; + __weak IBOutlet NSTextField *lsynthExecutablePath; + __weak IBOutlet NSTextField *lsynthConfigurationPath; + __weak IBOutlet NSMatrix *lsynthSelectionModeMatrix; + __weak IBOutlet NSSlider *lsynthTransparencySlider; + __weak IBOutlet NSTextField *lsynthTransparencyText; + __weak IBOutlet NSColorWell *lsynthSelectionColorWell; + __weak IBOutlet NSButton *lsynthSaveSynthesizedParts; + __weak IBOutlet NSView *lsynthExecutableChooserAccessoryView; + __weak IBOutlet NSView *lsynthConfigurationChooserAccessoryView; + __weak NSTextField *lsynthTransparencyNumberChanged; + __weak IBOutlet NSButton *lsynthShowBasicPartsList; // Miscellaneous - IBOutlet NSView *folderChooserAccessoryView; + __weak IBOutlet NSView *folderChooserAccessoryView; } //Initialization diff --git a/trunk/Bricksmith/Source/Application/General/PreferencesDialogController.m b/trunk/Bricksmith/Source/Application/General/PreferencesDialogController.m index 0166458..552177e 100644 --- a/trunk/Bricksmith/Source/Application/General/PreferencesDialogController.m +++ b/trunk/Bricksmith/Source/Application/General/PreferencesDialogController.m @@ -62,9 +62,9 @@ @interface PreferencesDialogController () // General Tab -@property (nonatomic, unsafe_unretained) IBOutlet NSTextField* gridSpacingFineField; -@property (nonatomic, unsafe_unretained) IBOutlet NSTextField* gridSpacingMediumField; -@property (nonatomic, unsafe_unretained) IBOutlet NSTextField* gridSpacingCoarseField; +@property (nonatomic, weak) IBOutlet NSTextField* gridSpacingFineField; +@property (nonatomic, weak) IBOutlet NSTextField* gridSpacingMediumField; +@property (nonatomic, weak) IBOutlet NSTextField* gridSpacingCoarseField; @end @@ -89,9 +89,9 @@ - (void) awakeFromNib { //Grab the current window content from the Nib (it should be blank). // We will display this while changing panes. - blankContent = [[preferencesWindow contentView] retain]; + blankContent = [preferencesWindow contentView]; - NSToolbar *tabToolbar = [[[NSToolbar alloc] initWithIdentifier:@"Preferences"] autorelease]; + NSToolbar *tabToolbar = [[NSToolbar alloc] initWithIdentifier:@"Preferences"]; [tabToolbar setDelegate:self]; [preferencesWindow setToolbar:tabToolbar]; @@ -901,7 +901,7 @@ - (NSToolbarItem *)toolbar:(NSToolbar *)toolbar [newItem setTarget:self]; [newItem setAction:@selector(changeTab:)]; - return [newItem autorelease]; + return newItem; }//end toolbar:itemForItemIdentifier:willBeInsertedIntoToolbar: @@ -929,9 +929,6 @@ - (BOOL) windowShouldClose:(id)sender // we have to track in manually. [self->preferencesWindow saveFrameUsingName:PREFERENCES_WINDOW_AUTOSAVE_NAME]; - //Make sure our memory is all released. - [preferencesDialog autorelease]; - return YES; }//end windowShouldClose: @@ -1291,16 +1288,12 @@ - (void)controlTextDidEndEditing:(NSNotification *)aNotification //============================================================================== - (void) dealloc { - [generalTabContentView release]; - [preferencesWindow release]; - [blankContent release]; + CFRelease((__bridge CFTypeRef)(preferencesDialog)); //clear out our global preferences controller. // It will be reinitialized when needed. preferencesDialog = nil; - [super dealloc]; - }//end dealloc @end diff --git a/trunk/Bricksmith/Source/Application/General/RelatedParts.m b/trunk/Bricksmith/Source/Application/General/RelatedParts.m index 5e00ddc..8f3afb2 100644 --- a/trunk/Bricksmith/Source/Application/General/RelatedParts.m +++ b/trunk/Bricksmith/Source/Application/General/RelatedParts.m @@ -24,7 +24,7 @@ //------------------------------------------------------------------------------ static NSInteger sort_by_part_description(id a, id b, void * ref) { - PartLibrary * pl = (PartLibrary *) ref; + PartLibrary * pl = (__bridge PartLibrary *) ref; NSString * aa = a; NSString * bb = b; @@ -129,18 +129,17 @@ - (id) initWithParent:(NSString *) parentName transform[11] = 0.0f; transform[15] = 1.0f; - self->child = [[line stringByTrimmingCharactersInSet:whitespaceCharacterSet] retain]; + self->child = [line stringByTrimmingCharactersInSet:whitespaceCharacterSet]; - self->childName = [[[PartLibrary sharedPartLibrary] descriptionForPartName:self->child] retain]; + self->childName = [[PartLibrary sharedPartLibrary] descriptionForPartName:self->child]; - self->role = [relation retain]; + self->role = relation; - self->parent = [parentName retain]; + self->parent = parentName; } @catch (NSException * e) { NSLog(@"a related part line '%@' was fatally invalid", orig); NSLog(@" raised exception %@", [e name]); - [self release]; self = nil; } @@ -148,21 +147,6 @@ - (id) initWithParent:(NSString *) parentName }//end initWithParent:offset:relation:childLine: -//========== dealloc =========================================================== -// -// Purpose: Beam me out, Scotty! -// -//============================================================================== -- (void) dealloc -{ - [parent release]; - [child release]; - [childName release]; - [role release]; - [super dealloc]; -}//end dealloc - - //========== dump ============================================================== // // Purpose: Print out a debug view of this relation for diagnostics. @@ -380,8 +364,6 @@ - (id) initWithFilePath:(NSString *)filePath NSString * pname = [parents objectAtIndex:pidx]; RelatedPart * p = [[RelatedPart alloc] initWithParent:pname offset:offset relation:relName childLine:line]; [arr addObject:p]; - [p release]; - } } } @@ -395,20 +377,6 @@ - (id) initWithFilePath:(NSString *)filePath }//end initWithFilePath: -//========== dealloc =========================================================== -// -// Purpose: My name is John D. Alec, but you can call me Mr. Alec. -// -//============================================================================== -- (void) dealloc -{ - [self->relatedParts release]; - - [super dealloc]; - -}//end dealloc - - //========== getChildPartList: ================================================= // // Purpose: Given a parent part file name, return a sorted array of child @@ -433,7 +401,7 @@ - (NSArray*) getChildPartList:(NSString *)parent } NSArray * kids_sorted = [kids allObjects]; - return [kids_sorted sortedArrayUsingFunction:sort_by_part_description context:[PartLibrary sharedPartLibrary]]; + return [kids_sorted sortedArrayUsingFunction:sort_by_part_description context:(__bridge void *)([PartLibrary sharedPartLibrary])]; }//end getChildPartList: diff --git a/trunk/Bricksmith/Source/Application/General/ToolPalette.h b/trunk/Bricksmith/Source/Application/General/ToolPalette.h index bcaa5a9..5a433eb 100644 --- a/trunk/Bricksmith/Source/Application/General/ToolPalette.h +++ b/trunk/Bricksmith/Source/Application/General/ToolPalette.h @@ -52,9 +52,9 @@ typedef enum NSPanel *palettePanel; //Nib connections - IBOutlet NSView *paletteContents; - IBOutlet NSMatrix *toolButtons; - IBOutlet LDrawColorWell *colorWell; + __weak IBOutlet NSView *paletteContents; + __weak IBOutlet NSMatrix *toolButtons; + __weak IBOutlet LDrawColorWell *colorWell; } diff --git a/trunk/Bricksmith/Source/Application/General/ToolPalette.m b/trunk/Bricksmith/Source/Application/General/ToolPalette.m index 9acfce3..d45d69a 100644 --- a/trunk/Bricksmith/Source/Application/General/ToolPalette.m +++ b/trunk/Bricksmith/Source/Application/General/ToolPalette.m @@ -127,8 +127,6 @@ - (id) init [self->palettePanel orderFront:self]; } - [self->paletteContents release]; - return self; }//end init @@ -290,12 +288,10 @@ - (void) keyboardDidChange:(NSNotification *)notification switch([theEvent type]) { case NSKeyDown: - [self->currentKeyCharacters release]; - self->currentKeyCharacters = [[theEvent charactersIgnoringModifiers] retain]; + self->currentKeyCharacters = [theEvent charactersIgnoringModifiers]; break; case NSKeyUp: - [self->currentKeyCharacters release]; self->currentKeyCharacters = @""; break; @@ -387,8 +383,6 @@ - (void) applicationDidBecomeActive:(NSNotification *)notification //clear the keys. We don't know what they are now, since Bricksmith wasn't // active to keep track of them. - [self->currentKeyCharacters release]; - self->currentKeyCharacters = @""; self->currentKeyModifiers = 0; @@ -610,10 +604,6 @@ - (void) dealloc [[NSNotificationCenter defaultCenter] removeObserver:self]; sharedToolPalette = nil; - [palettePanel release]; - - [super dealloc]; - }//end dealloc @end diff --git a/trunk/Bricksmith/Source/Application/Inspector/InspectionComment.h b/trunk/Bricksmith/Source/Application/Inspector/InspectionComment.h index f596075..e8d3072 100644 --- a/trunk/Bricksmith/Source/Application/Inspector/InspectionComment.h +++ b/trunk/Bricksmith/Source/Application/Inspector/InspectionComment.h @@ -13,7 +13,7 @@ @interface InspectionComment : ObjectInspectionController { - IBOutlet NSTextField *commandField; + __weak IBOutlet NSTextField *commandField; } diff --git a/trunk/Bricksmith/Source/Application/Inspector/InspectionConditionalLine.m b/trunk/Bricksmith/Source/Application/Inspector/InspectionConditionalLine.m index 68e81d5..28800be 100644 --- a/trunk/Bricksmith/Source/Application/Inspector/InspectionConditionalLine.m +++ b/trunk/Bricksmith/Source/Application/Inspector/InspectionConditionalLine.m @@ -16,23 +16,23 @@ @interface InspectionConditionalLine () -@property (nonatomic, unsafe_unretained) IBOutlet LDrawColorWell* colorWell; +@property (nonatomic, weak) IBOutlet LDrawColorWell* colorWell; -@property (nonatomic, unsafe_unretained) IBOutlet NSTextField* vertex1XField; -@property (nonatomic, unsafe_unretained) IBOutlet NSTextField* vertex1YField; -@property (nonatomic, unsafe_unretained) IBOutlet NSTextField* vertex1ZField; +@property (nonatomic, weak) IBOutlet NSTextField* vertex1XField; +@property (nonatomic, weak) IBOutlet NSTextField* vertex1YField; +@property (nonatomic, weak) IBOutlet NSTextField* vertex1ZField; -@property (nonatomic, unsafe_unretained) IBOutlet NSTextField* vertex2XField; -@property (nonatomic, unsafe_unretained) IBOutlet NSTextField* vertex2YField; -@property (nonatomic, unsafe_unretained) IBOutlet NSTextField* vertex2ZField; +@property (nonatomic, weak) IBOutlet NSTextField* vertex2XField; +@property (nonatomic, weak) IBOutlet NSTextField* vertex2YField; +@property (nonatomic, weak) IBOutlet NSTextField* vertex2ZField; -@property (nonatomic, unsafe_unretained) IBOutlet NSTextField* conditionalVertex1XField; -@property (nonatomic, unsafe_unretained) IBOutlet NSTextField* conditionalVertex1YField; -@property (nonatomic, unsafe_unretained) IBOutlet NSTextField* conditionalVertex1ZField; +@property (nonatomic, weak) IBOutlet NSTextField* conditionalVertex1XField; +@property (nonatomic, weak) IBOutlet NSTextField* conditionalVertex1YField; +@property (nonatomic, weak) IBOutlet NSTextField* conditionalVertex1ZField; -@property (nonatomic, unsafe_unretained) IBOutlet NSTextField* conditionalVertex2XField; -@property (nonatomic, unsafe_unretained) IBOutlet NSTextField* conditionalVertex2YField; -@property (nonatomic, unsafe_unretained) IBOutlet NSTextField* conditionalVertex2ZField; +@property (nonatomic, weak) IBOutlet NSTextField* conditionalVertex2XField; +@property (nonatomic, weak) IBOutlet NSTextField* conditionalVertex2YField; +@property (nonatomic, weak) IBOutlet NSTextField* conditionalVertex2ZField; @end diff --git a/trunk/Bricksmith/Source/Application/Inspector/InspectionLSynth.h b/trunk/Bricksmith/Source/Application/Inspector/InspectionLSynth.h index 91a3b8f..b9b7130 100644 --- a/trunk/Bricksmith/Source/Application/Inspector/InspectionLSynth.h +++ b/trunk/Bricksmith/Source/Application/Inspector/InspectionLSynth.h @@ -15,14 +15,14 @@ @interface InspectionLSynth : ObjectInspectionController { - IBOutlet NSTextField *lsynthPartLabel; - IBOutlet NSTextField *synthesizedPartCount; - IBOutlet NSMatrix *lsynthClassChooserMatrix; - IBOutlet NSTextField *SynthTypeLabel; - IBOutlet NSPopUpButton *typePopup; - IBOutlet NSPopUpButton *constraintDefaultPopup; - IBOutlet NSPopUpButton *defaultConstraints; - IBOutlet LDrawColorWell *colorWell; + __weak IBOutlet NSTextField *lsynthPartLabel; + __weak IBOutlet NSTextField *synthesizedPartCount; + __weak IBOutlet NSMatrix *lsynthClassChooserMatrix; + __weak IBOutlet NSTextField *SynthTypeLabel; + __weak IBOutlet NSPopUpButton *typePopup; + __weak IBOutlet NSPopUpButton *constraintDefaultPopup; + __weak IBOutlet NSPopUpButton *defaultConstraints; + __weak IBOutlet LDrawColorWell *colorWell; } //@property(nonatomic, retain) NSPopUpButton *typePopup; diff --git a/trunk/Bricksmith/Source/Application/Inspector/InspectionLSynth.m b/trunk/Bricksmith/Source/Application/Inspector/InspectionLSynth.m index 49df6b0..59681dc 100644 --- a/trunk/Bricksmith/Source/Application/Inspector/InspectionLSynth.m +++ b/trunk/Bricksmith/Source/Application/Inspector/InspectionLSynth.m @@ -370,18 +370,4 @@ - (void) updateSynthTypeLabel:(LSynthClassT)tag } -#pragma mark - -#pragma mark DESTRUCTOR -#pragma mark - - -//========== dealloc =========================================================== -// -// Purpose: Cockle warming for larger ladies -// -//============================================================================== -- (void)dealloc { - // [typePopup release]; - [super dealloc]; -}//end dealloc - @end diff --git a/trunk/Bricksmith/Source/Application/Inspector/InspectionLine.m b/trunk/Bricksmith/Source/Application/Inspector/InspectionLine.m index 7e25748..1361ca9 100644 --- a/trunk/Bricksmith/Source/Application/Inspector/InspectionLine.m +++ b/trunk/Bricksmith/Source/Application/Inspector/InspectionLine.m @@ -17,15 +17,15 @@ @interface InspectionLine () -@property (nonatomic, unsafe_unretained) IBOutlet LDrawColorWell* colorWell; +@property (nonatomic, weak) IBOutlet LDrawColorWell* colorWell; -@property (nonatomic, unsafe_unretained) IBOutlet NSTextField* startPointXField; -@property (nonatomic, unsafe_unretained) IBOutlet NSTextField* startPointYField; -@property (nonatomic, unsafe_unretained) IBOutlet NSTextField* startPointZField; +@property (nonatomic, weak) IBOutlet NSTextField* startPointXField; +@property (nonatomic, weak) IBOutlet NSTextField* startPointYField; +@property (nonatomic, weak) IBOutlet NSTextField* startPointZField; -@property (nonatomic, unsafe_unretained) IBOutlet NSTextField* endPointXField; -@property (nonatomic, unsafe_unretained) IBOutlet NSTextField* endPointYField; -@property (nonatomic, unsafe_unretained) IBOutlet NSTextField* endPointZField; +@property (nonatomic, weak) IBOutlet NSTextField* endPointXField; +@property (nonatomic, weak) IBOutlet NSTextField* endPointYField; +@property (nonatomic, weak) IBOutlet NSTextField* endPointZField; @end diff --git a/trunk/Bricksmith/Source/Application/Inspector/InspectionMPDModel.h b/trunk/Bricksmith/Source/Application/Inspector/InspectionMPDModel.h index d2dc159..be06e1c 100644 --- a/trunk/Bricksmith/Source/Application/Inspector/InspectionMPDModel.h +++ b/trunk/Bricksmith/Source/Application/Inspector/InspectionMPDModel.h @@ -13,12 +13,12 @@ @interface InspectionMPDModel : ObjectInspectionController { - IBOutlet NSTextField *modelNameField; - IBOutlet NSTextField *descriptionField; - IBOutlet NSTextField *authorField; + __weak IBOutlet NSTextField *modelNameField; + __weak IBOutlet NSTextField *descriptionField; + __weak IBOutlet NSTextField *authorField; - IBOutlet NSTextField *numberStepsField; - IBOutlet NSTextField *numberElementsField; + __weak IBOutlet NSTextField *numberStepsField; + __weak IBOutlet NSTextField *numberElementsField; } //Actions diff --git a/trunk/Bricksmith/Source/Application/Inspector/InspectionMPDModel.m b/trunk/Bricksmith/Source/Application/Inspector/InspectionMPDModel.m index 1dcf3ad..1253bd7 100644 --- a/trunk/Bricksmith/Source/Application/Inspector/InspectionMPDModel.m +++ b/trunk/Bricksmith/Source/Application/Inspector/InspectionMPDModel.m @@ -147,8 +147,6 @@ - (IBAction) modelNameFieldChanged:(id)sender // changes, but that's what the Finder does! (And it's easy.) newValue = oldValue; [self->modelNameField setStringValue:newValue]; - - [alert release]; } diff --git a/trunk/Bricksmith/Source/Application/Inspector/InspectionPart.m b/trunk/Bricksmith/Source/Application/Inspector/InspectionPart.m index f4acee2..0e2bcd5 100644 --- a/trunk/Bricksmith/Source/Application/Inspector/InspectionPart.m +++ b/trunk/Bricksmith/Source/Application/Inspector/InspectionPart.m @@ -32,32 +32,32 @@ @interface InspectionPart () // Top-level objects -@property (nonatomic, strong) IBOutlet NSNumberFormatter* formatterBasic; -@property (nonatomic, strong) IBOutlet NSNumberFormatter* formatterAngle; -@property (nonatomic, strong) IBOutlet NSNumberFormatter* formatterScale; +@property (nonatomic, weak) IBOutlet NSNumberFormatter* formatterBasic; +@property (nonatomic, weak) IBOutlet NSNumberFormatter* formatterAngle; +@property (nonatomic, weak) IBOutlet NSNumberFormatter* formatterScale; // Window widgets -@property (nonatomic, unsafe_unretained) IBOutlet NSTextField* partDescriptionField; -@property (nonatomic, unsafe_unretained) IBOutlet NSTextField* partNameField; -@property (nonatomic, unsafe_unretained) IBOutlet LDrawColorWell* colorWell; -@property (nonatomic, unsafe_unretained) IBOutlet NSPopUpButton* rotationTypePopUp; +@property (nonatomic, weak) IBOutlet NSTextField* partDescriptionField; +@property (nonatomic, weak) IBOutlet NSTextField* partNameField; +@property (nonatomic, weak) IBOutlet LDrawColorWell* colorWell; +@property (nonatomic, weak) IBOutlet NSPopUpButton* rotationTypePopUp; -@property (nonatomic, unsafe_unretained) IBOutlet NSTextField* locationXField; -@property (nonatomic, unsafe_unretained) IBOutlet NSTextField* locationYField; -@property (nonatomic, unsafe_unretained) IBOutlet NSTextField* locationZField; +@property (nonatomic, weak) IBOutlet NSTextField* locationXField; +@property (nonatomic, weak) IBOutlet NSTextField* locationYField; +@property (nonatomic, weak) IBOutlet NSTextField* locationZField; -@property (nonatomic, unsafe_unretained) IBOutlet NSTextField* rotationXField; -@property (nonatomic, unsafe_unretained) IBOutlet NSTextField* rotationYField; -@property (nonatomic, unsafe_unretained) IBOutlet NSTextField* rotationZField; +@property (nonatomic, weak) IBOutlet NSTextField* rotationXField; +@property (nonatomic, weak) IBOutlet NSTextField* rotationYField; +@property (nonatomic, weak) IBOutlet NSTextField* rotationZField; -@property (nonatomic, unsafe_unretained) IBOutlet NSTextField* scaleXField; -@property (nonatomic, unsafe_unretained) IBOutlet NSTextField* scaleYField; -@property (nonatomic, unsafe_unretained) IBOutlet NSTextField* scaleZField; +@property (nonatomic, weak) IBOutlet NSTextField* scaleXField; +@property (nonatomic, weak) IBOutlet NSTextField* scaleYField; +@property (nonatomic, weak) IBOutlet NSTextField* scaleZField; -@property (nonatomic, unsafe_unretained) IBOutlet NSTextField* shearXYField; -@property (nonatomic, unsafe_unretained) IBOutlet NSTextField* shearXZField; -@property (nonatomic, unsafe_unretained) IBOutlet NSTextField* shearYZField; +@property (nonatomic, weak) IBOutlet NSTextField* shearXYField; +@property (nonatomic, weak) IBOutlet NSTextField* shearXZField; +@property (nonatomic, weak) IBOutlet NSTextField* shearYZField; @end @@ -86,10 +86,6 @@ - (id) init - (void) awakeFromNib { [super awakeFromNib]; - - [_formatterBasic autorelease]; - [_formatterAngle autorelease]; - [_formatterScale autorelease]; } @@ -381,25 +377,4 @@ - (IBAction) shearEndedEditing:(id)sender }//end shearEndedEditing: -#pragma mark - -#pragma mark DESTRUCTOR -#pragma mark - - -//========== dealloc =========================================================== -// -// Purpose: Abandon all hope ye who enter here. -// -//============================================================================== -- (void) dealloc -{ - //Top level nib objects: - [_formatterBasic release]; - [_formatterAngle release]; - [_formatterScale release]; - - [super dealloc]; - -}//end dealloc - - @end diff --git a/trunk/Bricksmith/Source/Application/Inspector/InspectionQuadrilateral.m b/trunk/Bricksmith/Source/Application/Inspector/InspectionQuadrilateral.m index 157dfca..913ffaa 100644 --- a/trunk/Bricksmith/Source/Application/Inspector/InspectionQuadrilateral.m +++ b/trunk/Bricksmith/Source/Application/Inspector/InspectionQuadrilateral.m @@ -47,23 +47,23 @@ - (void) drawRect:(NSRect)rect @interface InspectionQuadrilateral () -@property (nonatomic, unsafe_unretained) IBOutlet LDrawColorWell* colorWell; +@property (nonatomic, weak) IBOutlet LDrawColorWell* colorWell; -@property (nonatomic, unsafe_unretained) IBOutlet NSTextField* vertex1XField; -@property (nonatomic, unsafe_unretained) IBOutlet NSTextField* vertex1YField; -@property (nonatomic, unsafe_unretained) IBOutlet NSTextField* vertex1ZField; +@property (nonatomic, weak) IBOutlet NSTextField* vertex1XField; +@property (nonatomic, weak) IBOutlet NSTextField* vertex1YField; +@property (nonatomic, weak) IBOutlet NSTextField* vertex1ZField; -@property (nonatomic, unsafe_unretained) IBOutlet NSTextField* vertex2XField; -@property (nonatomic, unsafe_unretained) IBOutlet NSTextField* vertex2YField; -@property (nonatomic, unsafe_unretained) IBOutlet NSTextField* vertex2ZField; +@property (nonatomic, weak) IBOutlet NSTextField* vertex2XField; +@property (nonatomic, weak) IBOutlet NSTextField* vertex2YField; +@property (nonatomic, weak) IBOutlet NSTextField* vertex2ZField; -@property (nonatomic, unsafe_unretained) IBOutlet NSTextField* vertex3XField; -@property (nonatomic, unsafe_unretained) IBOutlet NSTextField* vertex3YField; -@property (nonatomic, unsafe_unretained) IBOutlet NSTextField* vertex3ZField; +@property (nonatomic, weak) IBOutlet NSTextField* vertex3XField; +@property (nonatomic, weak) IBOutlet NSTextField* vertex3YField; +@property (nonatomic, weak) IBOutlet NSTextField* vertex3ZField; -@property (nonatomic, unsafe_unretained) IBOutlet NSTextField* vertex4XField; -@property (nonatomic, unsafe_unretained) IBOutlet NSTextField* vertex4YField; -@property (nonatomic, unsafe_unretained) IBOutlet NSTextField* vertex4ZField; +@property (nonatomic, weak) IBOutlet NSTextField* vertex4XField; +@property (nonatomic, weak) IBOutlet NSTextField* vertex4YField; +@property (nonatomic, weak) IBOutlet NSTextField* vertex4ZField; @end diff --git a/trunk/Bricksmith/Source/Application/Inspector/InspectionStep.h b/trunk/Bricksmith/Source/Application/Inspector/InspectionStep.h index e2c9586..dc3fb48 100644 --- a/trunk/Bricksmith/Source/Application/Inspector/InspectionStep.h +++ b/trunk/Bricksmith/Source/Application/Inspector/InspectionStep.h @@ -30,15 +30,15 @@ typedef enum //////////////////////////////////////////////////////////////////////////////// @interface InspectionStep : ObjectInspectionController { - IBOutlet NSMatrix *rotationTypeRadioButtons; + __weak IBOutlet NSMatrix *rotationTypeRadioButtons; - IBOutlet NSPopUpButton *relativeRotationPopUpMenu; - IBOutlet NSPopUpButton *absoluteRotationPopUpMenu; + __weak IBOutlet NSPopUpButton *relativeRotationPopUpMenu; + __weak IBOutlet NSPopUpButton *absoluteRotationPopUpMenu; - IBOutlet NSTextField *rotationXField; - IBOutlet NSTextField *rotationYField; - IBOutlet NSTextField *rotationZField; - IBOutlet NSButton *useCurrentAngleButton; + __weak IBOutlet NSTextField *rotationXField; + __weak IBOutlet NSTextField *rotationYField; + __weak IBOutlet NSTextField *rotationZField; + __weak IBOutlet NSButton *useCurrentAngleButton; } // Constraints diff --git a/trunk/Bricksmith/Source/Application/Inspector/InspectionTriangle.m b/trunk/Bricksmith/Source/Application/Inspector/InspectionTriangle.m index 4a6ff5f..eea63a1 100644 --- a/trunk/Bricksmith/Source/Application/Inspector/InspectionTriangle.m +++ b/trunk/Bricksmith/Source/Application/Inspector/InspectionTriangle.m @@ -46,19 +46,19 @@ - (void)drawRect:(NSRect)rect @interface InspectionTriangle () -@property (nonatomic, unsafe_unretained) IBOutlet LDrawColorWell* colorWell; +@property (nonatomic, weak) IBOutlet LDrawColorWell* colorWell; -@property (nonatomic, unsafe_unretained) IBOutlet NSTextField* vertex1XField; -@property (nonatomic, unsafe_unretained) IBOutlet NSTextField* vertex1YField; -@property (nonatomic, unsafe_unretained) IBOutlet NSTextField* vertex1ZField; +@property (nonatomic, weak) IBOutlet NSTextField* vertex1XField; +@property (nonatomic, weak) IBOutlet NSTextField* vertex1YField; +@property (nonatomic, weak) IBOutlet NSTextField* vertex1ZField; -@property (nonatomic, unsafe_unretained) IBOutlet NSTextField* vertex2XField; -@property (nonatomic, unsafe_unretained) IBOutlet NSTextField* vertex2YField; -@property (nonatomic, unsafe_unretained) IBOutlet NSTextField* vertex2ZField; +@property (nonatomic, weak) IBOutlet NSTextField* vertex2XField; +@property (nonatomic, weak) IBOutlet NSTextField* vertex2YField; +@property (nonatomic, weak) IBOutlet NSTextField* vertex2ZField; -@property (nonatomic, unsafe_unretained) IBOutlet NSTextField* vertex3XField; -@property (nonatomic, unsafe_unretained) IBOutlet NSTextField* vertex3YField; -@property (nonatomic, unsafe_unretained) IBOutlet NSTextField* vertex3ZField; +@property (nonatomic, weak) IBOutlet NSTextField* vertex3XField; +@property (nonatomic, weak) IBOutlet NSTextField* vertex3YField; +@property (nonatomic, weak) IBOutlet NSTextField* vertex3ZField; @end diff --git a/trunk/Bricksmith/Source/Application/Inspector/InspectionUnknownCommand.h b/trunk/Bricksmith/Source/Application/Inspector/InspectionUnknownCommand.h index 583c409..056573a 100644 --- a/trunk/Bricksmith/Source/Application/Inspector/InspectionUnknownCommand.h +++ b/trunk/Bricksmith/Source/Application/Inspector/InspectionUnknownCommand.h @@ -13,7 +13,7 @@ @interface InspectionUnknownCommand : ObjectInspectionController { - IBOutlet NSTextField *commandField; + __weak IBOutlet NSTextField *commandField; } diff --git a/trunk/Bricksmith/Source/Application/Inspector/Inspector.h b/trunk/Bricksmith/Source/Application/Inspector/Inspector.h index 09ed25a..596d4c6 100644 --- a/trunk/Bricksmith/Source/Application/Inspector/Inspector.h +++ b/trunk/Bricksmith/Source/Application/Inspector/Inspector.h @@ -13,10 +13,10 @@ @interface Inspector : NSObject { - IBOutlet NSPanel *inspectorPanel; //the main window. - NSString *emptyInspectorTitle; //window title for empty selection - NSView *emptyInspectorView; //content view used for invalid inspections - IBOutlet NSTextField *errorTextField; //inside emptyInspectorView; use to explain the problem. + __weak IBOutlet NSPanel *inspectorPanel; //the main window. + __weak NSString *emptyInspectorTitle; //window title for empty selection + __weak NSView *emptyInspectorView; //content view used for invalid inspections + __weak IBOutlet NSTextField *errorTextField; //inside emptyInspectorView; use to explain the problem. ObjectInspectionController *currentInspector; //controller for the loaded inspector. diff --git a/trunk/Bricksmith/Source/Application/Inspector/Inspector.m b/trunk/Bricksmith/Source/Application/Inspector/Inspector.m index f324433..081eef5 100644 --- a/trunk/Bricksmith/Source/Application/Inspector/Inspector.m +++ b/trunk/Bricksmith/Source/Application/Inspector/Inspector.m @@ -45,8 +45,8 @@ - (id) init //When the Nib first loads, it contains the view we intend to use for an // empty inspector. - emptyInspectorTitle = [[inspectorPanel title] retain]; - emptyInspectorView = [[inspectorPanel contentView] retain]; + emptyInspectorTitle = [inspectorPanel title]; + emptyInspectorView = [inspectorPanel contentView]; //Display a message appropriate to inspecting nothing. [self inspectObject:nil]; @@ -189,7 +189,6 @@ - (void) unloadInspector // End any editing happening in the current inspector. It is very important // to do this *before* attempting to replace the inspector! [inspectorPanel makeFirstResponder:nil]; - [currentInspector release]; currentInspector = nil; } @@ -244,25 +243,4 @@ - (NSUndoManager *)windowWillReturnUndoManager:(NSWindow *)sender }//end windowWillReturnUndoManager: -#pragma mark - -#pragma mark DESTRUCTOR -#pragma mark - - -//========== dealloc =========================================================== -// -// Purpose: The Class Vanishes. -// -//============================================================================== -- (void) dealloc -{ - [inspectorPanel release]; - [emptyInspectorTitle release]; - [emptyInspectorView release]; - [currentInspector release]; - - [super dealloc]; - -}//end dealloc - - @end diff --git a/trunk/Bricksmith/Source/Application/Inspector/ObjectInspectionController.m b/trunk/Bricksmith/Source/Application/Inspector/ObjectInspectionController.m index 0c0f8a4..4e94c16 100644 --- a/trunk/Bricksmith/Source/Application/Inspector/ObjectInspectionController.m +++ b/trunk/Bricksmith/Source/Application/Inspector/ObjectInspectionController.m @@ -76,10 +76,6 @@ - (void) setObject:(id)newObject name:LDrawDirectiveDidChangeNotification object:nil ]; - //Retain-release in preparation for changing the instance variable. - [newObject retain]; - [editingObject release]; - //Update the the object being edited. editingObject = newObject; [self revert:self]; //calling revert should set the values of the palette. @@ -260,12 +256,6 @@ - (void) dealloc //Cancel notification registration [[NSNotificationCenter defaultCenter] removeObserver:self ]; - //Release top-level nib objects and instance variables. - [window release]; - [editingObject release]; - - [super dealloc]; - }//end dealloc diff --git a/trunk/Bricksmith/Source/Categories/OverlayViewCategory.m b/trunk/Bricksmith/Source/Categories/OverlayViewCategory.m index 1c1e0ce..519b6a4 100755 --- a/trunk/Bricksmith/Source/Categories/OverlayViewCategory.m +++ b/trunk/Bricksmith/Source/Categories/OverlayViewCategory.m @@ -66,8 +66,6 @@ - (void) addOverlayView:(NSView *)overlayView [self addSubview:helperView]; - [helperView release]; - }//end addOverlayView:ordered: diff --git a/trunk/Bricksmith/Source/LDraw/Commands/LDrawColor.m b/trunk/Bricksmith/Source/LDraw/Commands/LDrawColor.m index e73f519..48c1f9c 100644 --- a/trunk/Bricksmith/Source/LDraw/Commands/LDrawColor.m +++ b/trunk/Bricksmith/Source/LDraw/Commands/LDrawColor.m @@ -72,8 +72,8 @@ - (id)initWithCoder:(NSCoder *)decoder self->hasLuminance = [decoder decodeBoolForKey:@"hasLuminance"]; self->luminance = (uint8_t)[decoder decodeIntForKey:@"luminance"]; self->material = [decoder decodeIntForKey:@"material"]; - self->materialParameters = [[decoder decodeObjectForKey:@"materialParameters"] retain]; - self->name = [[decoder decodeObjectForKey:@"name"] retain]; + self->materialParameters = [decoder decodeObjectForKey:@"materialParameters"]; + self->name = [decoder decodeObjectForKey:@"name"]; return self; @@ -128,7 +128,7 @@ - (id) copyWithZone:(NSZone *)zone // return the object itself for its "copy." // // The -hash implementation will die if this is not the case. - return [self retain]; + return self; // LDrawColor *copied = (LDrawColor *)[super copyWithZone:zone]; // @@ -344,7 +344,7 @@ + (LDrawColor *) blendedColorForCode:(LDrawColorT)colorCode [blendedColor setColorRGBA:blendedComponents]; [blendedColor setName:[NSString stringWithFormat:@"BlendedColor%d", colorCode]]; - return [blendedColor autorelease]; + return blendedColor; }//end blendedColorForCode: @@ -605,7 +605,7 @@ - (NSString *) localizedName // Since spaces are verboten in !COLOUR directives, color names tend to // have a bunch of unsightly underscores in them. We don't want to show // that to the user. - NSMutableString *fixedName = [[[self name] mutableCopy] autorelease]; + NSMutableString *fixedName = [[self name] mutableCopy]; [fixedName replaceOccurrencesOfString:@"_" withString:@" " options:NSLiteralSearch range:NSMakeRange(0, [fixedName length])]; colorName = fixedName; @@ -761,9 +761,6 @@ - (void) setMaterial:(LDrawColorMaterialT)newValue //============================================================================== - (void) setMaterialParameters:(NSString *)newValue { - [newValue retain]; - [self->materialParameters release]; - self->materialParameters = newValue; }//end setMaterialParameters: @@ -777,9 +774,6 @@ - (void) setMaterialParameters:(NSString *)newValue //============================================================================== - (void) setName:(NSString *)newName { - [newName retain]; - [self->name release]; - self->name = newName; }//end setName: @@ -963,27 +957,6 @@ - (BOOL) scanHexString:(NSScanner *)hexScanner intoRGB:(GLfloat *)components }//end parseHexString:intoRGB: -#pragma mark - -#pragma mark DESTRUCTOR -#pragma mark - - -//========== dealloc =========================================================== -// -// Purpose: We're turning blue. -// -//============================================================================== -- (void) dealloc -{ - [materialParameters release]; - [name release]; - - [fakeComplimentColor release]; - - [super dealloc]; - -}//end dealloc - - @end @@ -1093,4 +1066,4 @@ void HSVtoRGB( float h, float s, float v, float *r, float *g, float *b ) *b = q; break; } -} \ No newline at end of file +} diff --git a/trunk/Bricksmith/Source/LDraw/Commands/LDrawConditionalLine.m b/trunk/Bricksmith/Source/LDraw/Commands/LDrawConditionalLine.m index 697c388..ee66111 100644 --- a/trunk/Bricksmith/Source/LDraw/Commands/LDrawConditionalLine.m +++ b/trunk/Bricksmith/Source/LDraw/Commands/LDrawConditionalLine.m @@ -132,7 +132,6 @@ - (id) initWithLines:(NSArray *)lines { NSLog(@"the conditional line primitive %@ was fatally invalid", [lines objectAtIndex:range.location]); NSLog(@" raised exception %@", [exception name]); - [self release]; self = nil; } diff --git a/trunk/Bricksmith/Source/LDraw/Commands/LDrawDrawableElement.m b/trunk/Bricksmith/Source/LDraw/Commands/LDrawDrawableElement.m index 6fd2160..ed76c3a 100644 --- a/trunk/Bricksmith/Source/LDraw/Commands/LDrawDrawableElement.m +++ b/trunk/Bricksmith/Source/LDraw/Commands/LDrawDrawableElement.m @@ -370,8 +370,6 @@ - (void) setHidden:(BOOL) flag //============================================================================== - (void) setLDrawColor:(LDrawColor *)newColor { - [newColor retain]; - [self->color release]; self->color = newColor; [self invalCache:(DisplayList)]; // Needed to force anyone who is cached to recompute the new DL with possibly baked color! diff --git a/trunk/Bricksmith/Source/LDraw/Commands/LDrawLSynth.m b/trunk/Bricksmith/Source/LDraw/Commands/LDrawLSynth.m index a18a1fe..f80825b 100644 --- a/trunk/Bricksmith/Source/LDraw/Commands/LDrawLSynth.m +++ b/trunk/Bricksmith/Source/LDraw/Commands/LDrawLSynth.m @@ -162,7 +162,6 @@ - (id) initWithLines:(NSArray *)lines [[self subdirectives] addObject:directive]; [directive setEnclosingDirective:self]; [directive addObserver:self]; - [directive release]; } // @@ -193,8 +192,6 @@ - (id) initWithLines:(NSArray *)lines else if (parserState == PARSER_PARSING_SYNTHESIZED) { [synthesizedParts addObject:newDirective]; } - - [newDirective release]; } // @@ -300,7 +297,7 @@ + (NSRange) rangeOfDirectiveBeginningAtIndex:(NSUInteger)index - (id) initWithCoder:(NSCoder *)decoder { // Initialize the object. We'll have somewhere to synthesize into. - [self init]; + if (!(self = [self init])) return nil; // Container Coder initialization. This repopulates our contained objects self = [super initWithCoder:decoder]; @@ -715,8 +712,6 @@ - (int) lsynthClass //============================================================================== - (void) setLsynthType:(NSString *)type { - [type retain]; - [self->synthType release]; self->synthType = type; }//end setLsynthType: @@ -815,8 +810,6 @@ - (void) setSubdirectiveSelected:(BOOL)flag - (void) setLDrawColor:(LDrawColor *)newColor { // Store the color - [newColor retain]; - [self->color release]; self->color = newColor; [self colorSelectedSynthesizedParts:[self isSelected]]; @@ -963,10 +956,6 @@ -(void)synthesize outFile = [outPipe fileHandleForReading]; errorFile = [errorPipe fileHandleForReading]; - [inPipe release]; - [outPipe release]; - [errorPipe release]; - // Launch the task [task launch]; @@ -1006,10 +995,6 @@ -(void)synthesize initWithData: data encoding: NSASCIIStringEncoding]; - [task release]; - [data release]; - [lsynthOutput autorelease]; - // Split the output into lines NSMutableArray *stringsArray = [NSMutableArray arrayWithArray:[lsynthOutput componentsSeparatedByCharactersInSet:[NSCharacterSet newlineCharacterSet]]]; @@ -1027,7 +1012,6 @@ -(void)synthesize inRange:NSMakeRange(0, 1) parentGroup:nil]; [synthesizedParts addObject:newDirective]; - [newDirective release]; } else if (extract == NO && startRange.length > 0) { extract = YES; } @@ -1064,7 +1048,7 @@ - (void)doAutoHullOnBand // Reintegrate our hull-determined data. We'll likely have multiple // points all on the hull, each associated with a single constraint. // This boils them down to a set of constraints on the hull. - NSMutableSet *hullConstraints = [[[NSMutableSet alloc] init] autorelease]; + NSMutableSet *hullConstraints = [[NSMutableSet alloc] init]; for (NSMutableDictionary *point in preparedData) { if ([[point objectForKey:@"inHull"] integerValue] == YES) { [hullConstraints addObject:[point objectForKey:@"directive"]]; @@ -1076,7 +1060,7 @@ - (void)doAutoHullOnBand // INSIDE/OUTSIDE constraints as we iterate over them. // We could modify the constraints in-place but recreating the // subdirectives array is simpler. - NSMutableArray *newConstraints = [[[NSMutableArray alloc] init] autorelease]; + NSMutableArray *newConstraints = [[NSMutableArray alloc] init]; for (i=0; i<[[self subdirectives] count]; i++) { LDrawPart *part = [[self subdirectives] objectAtIndex:i]; @@ -1088,7 +1072,6 @@ - (void)doAutoHullOnBand LDrawLSynthDirective *OUTSIDE = [[LDrawLSynthDirective alloc] init]; [OUTSIDE setStringValue:@"OUTSIDE"]; [newConstraints addObject:OUTSIDE]; - [OUTSIDE release]; } // This part is on the hull (i.e. INSIDE the band) and the next part is @@ -1100,7 +1083,6 @@ - (void)doAutoHullOnBand [OUTSIDE setStringValue:@"OUTSIDE"]; [newConstraints addObject:part]; [newConstraints addObject:OUTSIDE]; - [OUTSIDE release]; } // This part is not on the hull (i.e. OUTSIDE the band) and the next part IS @@ -1112,7 +1094,6 @@ - (void)doAutoHullOnBand [INSIDE setStringValue:@"INSIDE"]; [newConstraints addObject:part]; [newConstraints addObject:INSIDE]; - [INSIDE release]; } // The constraint has the same hull membership as the next one so @@ -1144,7 +1125,7 @@ - (NSMutableArray *)prepareAutoHullData { // We build up details for each constraint in mappedPoints as we progress. // The inverse of the first constraint's transformation moves it back to (0,0,0). // The same inverse transform will do similar for the other constraints - NSMutableArray *mappedPoints = [[[NSMutableArray alloc] init] autorelease]; + NSMutableArray *mappedPoints = [[NSMutableArray alloc] init]; Matrix4 transform = [[[self subdirectives] objectAtIndex:0] transformationMatrix]; Matrix4 inverseTransform = Matrix4Invert(transform); for (LDrawPart *part in [self subdirectives]) { @@ -1209,7 +1190,7 @@ - (NSMutableArray *)prepareAutoHullData { // We create a dictionary for each hull point for each mappedPoint // We'll reintegrate later to decide which constraints are in or out // (in doAutoHullOnBand) - NSMutableArray *preparedData = [[[NSMutableArray alloc] init] autorelease]; + NSMutableArray *preparedData = [[NSMutableArray alloc] init]; for (NSMutableDictionary *point in mappedPoints) { for (NSMutableDictionary *coords in [point objectForKey:@"hullPoints"]) { //NSLog(@"Point: %@", coords); @@ -1273,7 +1254,7 @@ - (void)colorSelectedSynthesizedParts:(BOOL)yesNo NSUserDefaults *userDefaults = [NSUserDefaults standardUserDefaults]; LSynthSelectionModeT selectionMode = [userDefaults integerForKey:LSYNTH_SELECTION_MODE_KEY]; GLfloat rgba[4]; // a temporary RGBA color we create and manipulate - LDrawColor *theColor = [[[LDrawColor alloc] init] autorelease]; // an LDrawColor to set the part's color with + LDrawColor *theColor = [[LDrawColor alloc] init]; // an LDrawColor to set the part's color with // Is the part selected? if (yesNo == YES) { @@ -1465,23 +1446,4 @@ -(void)requiresResynthesis:(id)sender [self noteNeedsDisplay]; } // end requiresResynthesis: -#pragma mark - -#pragma mark DESTRUCTOR -#pragma mark - - -//========== dealloc =========================================================== -// -// Purpose: Like sleeping. But, like, for ever. -// -//============================================================================== -- (void) dealloc -{ - [color release]; - [synthesizedParts release]; - [synthType release]; - - [super dealloc]; - -}//end dealloc - @end diff --git a/trunk/Bricksmith/Source/LDraw/Commands/LDrawLine.m b/trunk/Bricksmith/Source/LDraw/Commands/LDrawLine.m index e31ce3b..1aa23d0 100644 --- a/trunk/Bricksmith/Source/LDraw/Commands/LDrawLine.m +++ b/trunk/Bricksmith/Source/LDraw/Commands/LDrawLine.m @@ -106,7 +106,6 @@ - (id) initWithLines:(NSArray *)lines { NSLog(@"the line primitive %@ was fatally invalid", [lines objectAtIndex:range.location]); NSLog(@" raised exception %@", [exception name]); - [self release]; self = nil; } @@ -550,8 +549,8 @@ - (void) setSelected:(BOOL)flag if(flag == YES) { - LDrawDragHandle *handle1 = [[[LDrawDragHandle alloc] initWithTag:1 position:self->vertex1] autorelease]; - LDrawDragHandle *handle2 = [[[LDrawDragHandle alloc] initWithTag:2 position:self->vertex2] autorelease]; + LDrawDragHandle *handle1 = [[LDrawDragHandle alloc] initWithTag:1 position:self->vertex1]; + LDrawDragHandle *handle2 = [[LDrawDragHandle alloc] initWithTag:2 position:self->vertex2]; [handle1 setTarget:self]; [handle2 setTarget:self]; @@ -563,7 +562,6 @@ - (void) setSelected:(BOOL)flag } else { - [self->dragHandles release]; self->dragHandles = nil; } @@ -699,21 +697,4 @@ - (void) registerUndoActions:(NSUndoManager *)undoManager }//end registerUndoActions: -#pragma mark - -#pragma mark DESTRUCTOR -#pragma mark - - -//========== dealloc =========================================================== -// -// Purpose: Sleeping with the fishes. -// -//============================================================================== -- (void) dealloc -{ - [dragHandles release]; - - [super dealloc]; -} - - @end diff --git a/trunk/Bricksmith/Source/LDraw/Commands/LDrawMetaCommand.m b/trunk/Bricksmith/Source/LDraw/Commands/LDrawMetaCommand.m index 8c4811a..890cc64 100644 --- a/trunk/Bricksmith/Source/LDraw/Commands/LDrawMetaCommand.m +++ b/trunk/Bricksmith/Source/LDraw/Commands/LDrawMetaCommand.m @@ -122,7 +122,7 @@ - (id) initWithLines:(NSArray *)lines { // Didn't specifically recognize this metacommand. Create a // non-functional generic command to record its existence. - directive = [self retain]; + directive = self; NSString *command = [[scanner string] substringFromIndex:metaLineStart]; [directive setStringValue:command]; @@ -132,7 +132,7 @@ - (id) initWithLines:(NSArray *)lines { // This is presumably an empty line, and the following will // incorrectly add a 0 linetype to it. - directive = [self retain]; + directive = self; NSString *command = [scanner string]; [directive setStringValue:command]; @@ -150,7 +150,6 @@ - (id) initWithLines:(NSArray *)lines } // The new directive should replace the receiver! - [self release]; self = nil; return directive; @@ -169,7 +168,7 @@ - (id)initWithCoder:(NSCoder *)decoder { self = [super initWithCoder:decoder]; - commandString = [[decoder decodeObjectForKey:@"commandString"] retain]; + commandString = [decoder decodeObjectForKey:@"commandString"]; return self; @@ -313,9 +312,6 @@ - (NSString *) inspectorClassName //============================================================================== -(void) setStringValue:(NSString *)newString { - [newString retain]; - [commandString release]; - commandString = newString; }//end setStringValue: @@ -354,21 +350,4 @@ - (void) registerUndoActions:(NSUndoManager *)undoManager }//end registerUndoActions: -#pragma mark - -#pragma mark DESTRUCTOR -#pragma mark - - -//========== dealloc =========================================================== -// -// Purpose: Embraced by the light. -// -//============================================================================== -- (void) dealloc -{ - [commandString release]; - - [super dealloc]; - -}//end dealloc - @end diff --git a/trunk/Bricksmith/Source/LDraw/Commands/LDrawPart.m b/trunk/Bricksmith/Source/LDraw/Commands/LDrawPart.m index 8710cb8..36a8d85 100644 --- a/trunk/Bricksmith/Source/LDraw/Commands/LDrawPart.m +++ b/trunk/Bricksmith/Source/LDraw/Commands/LDrawPart.m @@ -213,7 +213,6 @@ - (id) initWithLines:(NSArray *)lines { NSLog(@"the part %@ was fatally invalid", [lines objectAtIndex:range.location]); NSLog(@" raised exception %@", [exception name]); - [self release]; self = nil; } @@ -953,13 +952,8 @@ - (void) setDisplayName:(NSString *)newPartName NSString *newReferenceName = [newPartName lowercaseString]; dispatch_group_t parseGroup = NULL; - [newPartName retain]; - [displayName release]; - displayName = newPartName; - [newReferenceName retain]; - [referenceName release]; referenceName = newReferenceName; assert(parentGroup == NULL || cacheType == PartTypeUnresolved); @@ -989,7 +983,6 @@ - (void) setDisplayName:(NSString *)newPartName if(parentGroup == NULL) { dispatch_group_wait(parseGroup, DISPATCH_TIME_FOREVER); - dispatch_release(parseGroup); } #endif } @@ -1487,7 +1480,6 @@ - (void) flattenIntoLines:(NSMutableArray *)lines normalTransform:normalTransform recursive:recursive ]; - [flatCopy release]; } }//end flattenIntoLines:triangles:quadrilaterals:other:currentColor: @@ -1709,18 +1701,20 @@ - (void) followRedirectionAndUpdate NSString * fileContents = [LDrawUtilities stringFromFile:partPath]; NSArray * lines = [fileContents separateByLine]; - dispatch_group_t parseGroup = dispatch_group_create(); + dispatch_group_t parseGroup = NULL; +#if USE_BLOCKS + parseGroup = dispatch_group_create(); +#endif LDrawFile * parsedFile = [[LDrawFile alloc] initWithLines:lines inRange:NSMakeRange(0, [lines count]) parentGroup:parseGroup]; +#if USE_BLOCKS // The part parser is insanely dangerous: it parses on a dispatch group and fills in your // NS containers in the background later, with no locks. We use a dispatch group to // wait until the entire mess of loading is done, synchronously, so the part is safe to look at. dispatch_group_wait(parseGroup, DISPATCH_TIME_FOREVER); - dispatch_release(parseGroup); - - [parsedFile autorelease]; // Don't keep this around , we only want it for its part. +#endif // We're going to go get all of the directives and try to find EXACTLY one LDrawPart. NSArray * directives = [parsedFile allEnclosedElements]; @@ -1754,6 +1748,7 @@ - (void) followRedirectionAndUpdate Matrix4 new_loc = Matrix4Multiply([redirect transformationMatrix], [self transformationMatrix]); Matrix4GetGLMatrix4(new_loc, glTransformation); } + } }// end followRedirectionAndUpdate @@ -1774,14 +1769,8 @@ - (void) dealloc { [self unresolvePart]; - //release instance variables. - [displayName release]; - [referenceName release]; - - cacheDrawable = (id) 0xDEADBEEF; - cacheModel = (id) 0xDEADBEEF; - - [super dealloc]; + cacheDrawable = nil; + cacheModel = nil; }//end dealloc diff --git a/trunk/Bricksmith/Source/LDraw/Commands/LDrawQuadrilateral.m b/trunk/Bricksmith/Source/LDraw/Commands/LDrawQuadrilateral.m index c688b5f..5ea02b0 100644 --- a/trunk/Bricksmith/Source/LDraw/Commands/LDrawQuadrilateral.m +++ b/trunk/Bricksmith/Source/LDraw/Commands/LDrawQuadrilateral.m @@ -132,7 +132,6 @@ - (id) initWithLines:(NSArray *)lines { NSLog(@"the quadrilateral primitive %@ was fatally invalid", [lines objectAtIndex:range.location]); NSLog(@" raised exception %@", [exception name]); - [self release]; self = nil; } @@ -753,10 +752,10 @@ - (void) setSelected:(BOOL)flag // Create the drag handle objects if(flag == YES) { - LDrawDragHandle *handle1 = [[[LDrawDragHandle alloc] initWithTag:1 position:self->vertex1] autorelease]; - LDrawDragHandle *handle2 = [[[LDrawDragHandle alloc] initWithTag:2 position:self->vertex2] autorelease]; - LDrawDragHandle *handle3 = [[[LDrawDragHandle alloc] initWithTag:3 position:self->vertex3] autorelease]; - LDrawDragHandle *handle4 = [[[LDrawDragHandle alloc] initWithTag:4 position:self->vertex4] autorelease]; + LDrawDragHandle *handle1 = [[LDrawDragHandle alloc] initWithTag:1 position:self->vertex1]; + LDrawDragHandle *handle2 = [[LDrawDragHandle alloc] initWithTag:2 position:self->vertex2]; + LDrawDragHandle *handle3 = [[LDrawDragHandle alloc] initWithTag:3 position:self->vertex3]; + LDrawDragHandle *handle4 = [[LDrawDragHandle alloc] initWithTag:4 position:self->vertex4]; [handle1 setTarget:self]; [handle2 setTarget:self]; @@ -772,7 +771,6 @@ - (void) setSelected:(BOOL)flag } else { - [self->dragHandles release]; self->dragHandles = nil; } @@ -1042,21 +1040,4 @@ - (void) registerUndoActions:(NSUndoManager *)undoManager }//end registerUndoActions: -#pragma mark - -#pragma mark DESTRUCTOR -#pragma mark - - -//========== dealloc =========================================================== -// -// Purpose: The Big Sleep. -// -//============================================================================== -- (void) dealloc -{ - [dragHandles release]; - - [super dealloc]; -} - - @end diff --git a/trunk/Bricksmith/Source/LDraw/Commands/LDrawTexture.m b/trunk/Bricksmith/Source/LDraw/Commands/LDrawTexture.m index 2462223..c5b6340 100755 --- a/trunk/Bricksmith/Source/LDraw/Commands/LDrawTexture.m +++ b/trunk/Bricksmith/Source/LDraw/Commands/LDrawTexture.m @@ -11,6 +11,7 @@ #import "LDrawDragHandle.h" #import "LDrawKeywords.h" +#import "LDrawStep.h" #import "LDrawUtilities.h" #import "PartLibrary.h" #import "StringCategory.h" @@ -116,7 +117,7 @@ - (id) initWithLines:(NSArray *)lines if(fallbackRange.location != NSNotFound) { // not even going to bother parsing this. - fallback = [[lines subarrayWithRange:fallbackRange] retain]; + fallback = [lines subarrayWithRange:fallbackRange]; } } @@ -152,7 +153,7 @@ - (id) initWithCoder:(NSCoder *)decoder temporary = [decoder decodeBytesForKey:@"planePoint3" returnedLength:NULL]; memcpy(&planePoint3, temporary, sizeof(Point3)); - self->fallback = [[decoder decodeObjectForKey:@"fallback"] retain]; + self->fallback = [decoder decodeObjectForKey:@"fallback"]; return self; @@ -679,8 +680,6 @@ - (NSString *) imageReferenceName //============================================================================== - (void) setGlossmapName:(NSString *)newName { - [newName retain]; - [self->glossmapName release]; self->glossmapName = newName; } @@ -714,12 +713,7 @@ - (void) setImageDisplayName:(NSString *)newName NSString *newReferenceName = [newName lowercaseString]; dispatch_group_t parseGroup = NULL; - [newName retain]; - [self->imageDisplayName release]; self->imageDisplayName = newName; - - [newReferenceName retain]; - [self->imageReferenceName release]; self->imageReferenceName = newReferenceName; // Force the part library to parse the model this part will display. This @@ -740,7 +734,6 @@ - (void) setImageDisplayName:(NSString *)newName if(parentGroup == NULL) { dispatch_group_wait(parseGroup, DISPATCH_TIME_FOREVER); - dispatch_release(parseGroup); } #endif } @@ -810,9 +803,9 @@ - (void) setSelected:(BOOL)flag if(flag == YES) { - LDrawDragHandle *handle1 = [[[LDrawDragHandle alloc] initWithTag:1 position:self->planePoint1] autorelease]; - LDrawDragHandle *handle2 = [[[LDrawDragHandle alloc] initWithTag:2 position:self->planePoint2] autorelease]; - LDrawDragHandle *handle3 = [[[LDrawDragHandle alloc] initWithTag:3 position:self->planePoint3] autorelease]; + LDrawDragHandle *handle1 = [[LDrawDragHandle alloc] initWithTag:1 position:self->planePoint1]; + LDrawDragHandle *handle2 = [[LDrawDragHandle alloc] initWithTag:2 position:self->planePoint2]; + LDrawDragHandle *handle3 = [[LDrawDragHandle alloc] initWithTag:3 position:self->planePoint3]; [handle1 setTarget:self]; [handle2 setTarget:self]; @@ -826,7 +819,6 @@ - (void) setSelected:(BOOL)flag } else { - [self->dragHandles release]; self->dragHandles = nil; } @@ -856,14 +848,12 @@ - (void) insertDirective:(LDrawDirective *)directive atIndex:(NSInteger)index //============================================================================== - (void) removeDirectiveAtIndex:(NSInteger)index { - LDrawDirective *directive = [[[self subdirectives] objectAtIndex:index] retain]; + LDrawDirective *directive = [[self subdirectives] objectAtIndex:index]; [super removeDirectiveAtIndex:index]; [self invalCache:CacheFlagBounds|DisplayList]; - [directive release]; - }//end removeDirectiveAtIndex: @@ -1129,7 +1119,6 @@ - (void) flattenIntoLines:(NSMutableArray *)lines [self removeDirectiveAtIndex:counter]; } - [fallback release]; fallback = nil; // Add back all the flattened geometry @@ -1154,25 +1143,4 @@ - (void) flattenIntoLines:(NSMutableArray *)lines }//end flattenIntoLines:triangles:quadrilaterals:other:currentColor: -#pragma mark - -#pragma mark DESTRUCTOR -#pragma mark - - -//========== dealloc =========================================================== -// -// Purpose: Think black fabric. Loosely cut. In a hood. -// -//============================================================================== -- (void) dealloc -{ - [fallback release]; - [imageDisplayName release]; - [imageReferenceName release]; - [glossmapName release]; - - [dragHandles release]; - - [super dealloc]; -} - @end diff --git a/trunk/Bricksmith/Source/LDraw/Commands/LDrawTriangle.m b/trunk/Bricksmith/Source/LDraw/Commands/LDrawTriangle.m index 47e24eb..ba618ec 100644 --- a/trunk/Bricksmith/Source/LDraw/Commands/LDrawTriangle.m +++ b/trunk/Bricksmith/Source/LDraw/Commands/LDrawTriangle.m @@ -120,7 +120,6 @@ - (id) initWithLines:(NSArray *)lines { NSLog(@"the triangle primitive %@ was fatally invalid", [lines objectAtIndex:range.location]); NSLog(@" raised exception %@", [exception name]); - [self release]; self = nil; } @@ -656,9 +655,9 @@ - (void) setSelected:(BOOL)flag if(flag == YES) { - LDrawDragHandle *handle1 = [[[LDrawDragHandle alloc] initWithTag:1 position:self->vertex1] autorelease]; - LDrawDragHandle *handle2 = [[[LDrawDragHandle alloc] initWithTag:2 position:self->vertex2] autorelease]; - LDrawDragHandle *handle3 = [[[LDrawDragHandle alloc] initWithTag:3 position:self->vertex3] autorelease]; + LDrawDragHandle *handle1 = [[LDrawDragHandle alloc] initWithTag:1 position:self->vertex1]; + LDrawDragHandle *handle2 = [[LDrawDragHandle alloc] initWithTag:2 position:self->vertex2]; + LDrawDragHandle *handle3 = [[LDrawDragHandle alloc] initWithTag:3 position:self->vertex3]; [handle1 setTarget:self]; [handle2 setTarget:self]; @@ -672,7 +671,6 @@ - (void) setSelected:(BOOL)flag } else { - [self->dragHandles release]; self->dragHandles = nil; } @@ -852,22 +850,5 @@ - (void) registerUndoActions:(NSUndoManager *)undoManager }//end registerUndoActions: -#pragma mark - -#pragma mark DESTRUCTOR -#pragma mark - - -//========== dealloc =========================================================== -// -// Purpose: Taking a dirt nap. -// -//============================================================================== -- (void) dealloc -{ - [dragHandles release]; - - [super dealloc]; -} - - @end diff --git a/trunk/Bricksmith/Source/LDraw/Files/LDrawContainer.m b/trunk/Bricksmith/Source/LDraw/Files/LDrawContainer.m index bb6144a..4147247 100644 --- a/trunk/Bricksmith/Source/LDraw/Files/LDrawContainer.m +++ b/trunk/Bricksmith/Source/LDraw/Files/LDrawContainer.m @@ -50,7 +50,7 @@ - (id)initWithCoder:(NSCoder *)decoder { self = [super initWithCoder:decoder]; - containedObjects = [[decoder decodeObjectForKey:@"containedObjects"] retain]; + containedObjects = [decoder decodeObjectForKey:@"containedObjects"]; for(id i in containedObjects) [i addObserver:self]; @@ -95,7 +95,6 @@ - (id) copyWithZone:(NSZone *)zone { copiedObject = [currentObject copy]; [copiedContainer insertDirective:copiedObject atIndex:counter]; - [copiedObject release]; } return copiedContainer; @@ -477,11 +476,6 @@ - (void) dealloc [self->containedObjects makeObjectsPerformSelector:@selector(setEnclosingDirective:) withObject:nil ]; - //release instance variables - [containedObjects release]; - - [super dealloc]; - }//end dealloc diff --git a/trunk/Bricksmith/Source/LDraw/Files/LDrawFile.h b/trunk/Bricksmith/Source/LDraw/Files/LDrawFile.h index ebc1c54..10b8228 100644 --- a/trunk/Bricksmith/Source/LDraw/Files/LDrawFile.h +++ b/trunk/Bricksmith/Source/LDraw/Files/LDrawFile.h @@ -28,9 +28,9 @@ //////////////////////////////////////////////////////////////////////////////// @interface LDrawFile : LDrawContainer { - NSDictionary *nameModelDict; - LDrawMPDModel *activeModel; - NSString *filePath; //where this file came from on disk. + NSDictionary *nameModelDict; + __weak LDrawMPDModel *activeModel; + NSString *filePath; //where this file came from on disk. } // Initialization diff --git a/trunk/Bricksmith/Source/LDraw/Files/LDrawFile.m b/trunk/Bricksmith/Source/LDraw/Files/LDrawFile.m index 05cd666..b5127fd 100644 --- a/trunk/Bricksmith/Source/LDraw/Files/LDrawFile.m +++ b/trunk/Bricksmith/Source/LDraw/Files/LDrawFile.m @@ -48,7 +48,7 @@ + (LDrawFile *) file [newFile addSubmodel:firstModel]; [newFile setActiveModel:firstModel]; - return [newFile autorelease]; + return newFile; }//end file @@ -87,7 +87,7 @@ + (LDrawFile *) parseFromFileContents:(NSString *) fileContents newFile = [[LDrawFile alloc] initWithLines:lines inRange:NSMakeRange(0, [lines count]) ]; - return [newFile autorelease]; + return newFile; }//end parseFromFileContents:allowThreads: @@ -129,7 +129,6 @@ - (void) updateModelLookupTable [names addObject:[[model modelName] lowercaseString]]; } - [self->nameModelDict release]; self->nameModelDict = [[NSDictionary alloc] initWithObjects:submodels forKeys:names]; } @@ -145,15 +144,17 @@ - (id) initWithLines:(NSArray *)lines inRange:(NSRange)range parentGroup:(dispatch_group_t)parentGroup { - NSRange modelRange = range; - NSUInteger modelStartIndex = range.location; - id *submodels = NULL; - NSUInteger insertIndex = 0; + NSRange modelRange = range; + NSUInteger modelStartIndex = range.location; + __strong LDrawMPDModel **submodels = NULL; + NSUInteger insertIndex = 0; self = [super initWithLines:lines inRange:range parentGroup:parentGroup]; if(self) { - submodels = calloc(range.length, sizeof(LDrawDirective*)); + // Creation a C array of retained pointers under ARC + // (see Transitioning to ARC Release Notes for details) + submodels = (__strong LDrawMPDModel **)calloc(range.length, sizeof(LDrawMPDModel *)); dispatch_group_t dispatchGroup = NULL; #if USE_BLOCKS dispatch_queue_t queue = dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0); @@ -203,7 +204,9 @@ - (id) initWithLines:(NSArray *)lines currentModel = submodels[counter]; [self addSubmodel:currentModel]; - [currentModel release]; + + // Tell ARC to release the object + submodels[counter] = nil; } if([[self submodels] count] > 0) @@ -216,7 +219,6 @@ - (id) initWithLines:(NSArray *)lines dispatch_group_leave(parentGroup); }); - dispatch_release(dispatchGroup); #endif } @@ -561,9 +563,6 @@ - (void) setActiveModel:(LDrawMPDModel *)newModel //Don't bother doing anything if we aren't really changing models. if(newModel != activeModel) { - [newModel retain]; - [activeModel release]; - //Update the active model and note that something happened. activeModel = newModel; if(postsNotifications) @@ -573,7 +572,6 @@ - (void) setActiveModel:(LDrawMPDModel *)newModel } else if (newModel == nil) { - [activeModel release];//why are we retaining?! activeModel = nil; } else @@ -624,9 +622,6 @@ - (void) setEnclosingDirective:(LDrawContainer *)newParent //============================================================================== - (void) setPath:(NSString *)newPath { - [newPath retain]; - [self->filePath release]; - self->filePath = newPath; }//end setPath: @@ -855,25 +850,4 @@ - (void) receiveMessage:(MessageT) msg who:(id) observable } -#pragma mark - -#pragma mark DESTRUCTOR -#pragma mark - - -//========== dealloc =========================================================== -// -// Purpose: Takin' care o' business. -// -//============================================================================== -- (void) dealloc -{ - //NSLog(@"File %s going away.\n", [filePath UTF8String]); - [nameModelDict release]; - [activeModel release]; - [filePath release]; - - [super dealloc]; - -}//end dealloc - - @end diff --git a/trunk/Bricksmith/Source/LDraw/Files/LDrawMPDModel.m b/trunk/Bricksmith/Source/LDraw/Files/LDrawMPDModel.m index 266f840..e7de269 100644 --- a/trunk/Bricksmith/Source/LDraw/Files/LDrawMPDModel.m +++ b/trunk/Bricksmith/Source/LDraw/Files/LDrawMPDModel.m @@ -62,7 +62,7 @@ + (id) model //============================================================================== - (id) init { - [super init]; + if (!(self = [super init])) return nil; modelName = @""; @@ -120,7 +120,7 @@ - (id) initWithLines:(NSArray *)lines } // Create a basic model. - [super initWithLines:lines inRange:nonMPDRange parentGroup:parentGroup]; //parses model into header and steps. + if (!(self = [super initWithLines:lines inRange:nonMPDRange parentGroup:parentGroup])) return nil; //parses model into header and steps. // If it wasn't MPD, we still need a model name. We can get that via the // parsed model. @@ -148,7 +148,7 @@ - (id)initWithCoder:(NSCoder *)decoder { self = [super initWithCoder:decoder]; - modelName = [[decoder decodeObjectForKey:@"modelName"] retain]; + modelName = [decoder decodeObjectForKey:@"modelName"]; return self; @@ -367,9 +367,6 @@ - (NSString *) modelName //============================================================================== - (void) setModelName:(NSString *)newModelName { - [newModelName retain]; - [modelName release]; - modelName = newModelName; [self sendMessageToObservers:MessageNameChanged]; @@ -523,22 +520,4 @@ - (void) registerUndoActions:(NSUndoManager *)undoManager }//end registerUndoActions: -#pragma mark - -#pragma mark DESTRUCTOR -#pragma mark - - -//========== dealloc =========================================================== -// -// Purpose: Time to send the cows home. -// -//============================================================================== -- (void) dealloc -{ - [modelName release]; - - [super dealloc]; - -}//end dealloc - - @end diff --git a/trunk/Bricksmith/Source/LDraw/Files/LDrawModel.m b/trunk/Bricksmith/Source/LDraw/Files/LDrawModel.m index c7b7219..ca31829 100644 --- a/trunk/Bricksmith/Source/LDraw/Files/LDrawModel.m +++ b/trunk/Bricksmith/Source/LDraw/Files/LDrawModel.m @@ -67,7 +67,7 @@ + (id) model //Need to create a blank step. [newModel addStep]; - return [newModel autorelease]; + return newModel; }//end model @@ -117,17 +117,19 @@ - (id) initWithLines:(NSArray *)lines inRange:(NSRange)range parentGroup:(dispatch_group_t)parentGroup { - NSUInteger contentStartIndex = 0; - NSRange stepRange = range; - NSUInteger maxLineIndex = 0; - NSUInteger insertIndex = 0; - id * substeps = NULL; + NSUInteger contentStartIndex = 0; + NSRange stepRange = range; + NSUInteger maxLineIndex = 0; + NSUInteger insertIndex = 0; + __strong LDrawStep **substeps = NULL; //Start with a nice blank model. self = [super initWithLines:lines inRange:range parentGroup:parentGroup]; self->cachedBounds = InvalidBox; - substeps = calloc(range.length, sizeof(LDrawDirective*)); + // Creation a C array of retained pointers under ARC + // (see Transitioning to ARC Release Notes for details) + substeps = (__strong LDrawStep **)calloc(range.length, sizeof(LDrawStep *)); //Try and get the header out of the file. If it's there, the lines returned // will not contain it. @@ -172,7 +174,9 @@ - (id) initWithLines:(NSArray *)lines LDrawStep * step = substeps[counter]; [self addStep:step]; - [step release]; + + // Tell ARC to release the object + substeps[counter] = nil; } free(substeps); @@ -187,7 +191,6 @@ - (id) initWithLines:(NSArray *)lines if(parentGroup != NULL) dispatch_group_leave(parentGroup); }); - dispatch_release(modelDispatchGroup); #endif return self; @@ -207,9 +210,9 @@ - (id) initWithCoder:(NSCoder *)decoder self->cachedBounds = InvalidBox; [self invalCache:CacheFlagBounds]; - modelDescription = [[decoder decodeObjectForKey:@"modelDescription"] retain]; - fileName = [[decoder decodeObjectForKey:@"fileName"] retain]; - author = [[decoder decodeObjectForKey:@"author"] retain]; + modelDescription = [decoder decodeObjectForKey:@"modelDescription"]; + fileName = [decoder decodeObjectForKey:@"fileName"]; + author = [decoder decodeObjectForKey:@"author"]; return self; @@ -1045,9 +1048,6 @@ - (void) setDraggingDirectives:(NSArray *)directives recursive:NO]; } - [dragStep retain]; - [self->draggingDirectives release]; - self->draggingDirectives = dragStep; }//end setDraggingDirectives: @@ -1060,9 +1060,6 @@ - (void) setDraggingDirectives:(NSArray *)directives //============================================================================== - (void) setModelDescription:(NSString *)newDescription { - [newDescription retain]; - [modelDescription release]; - modelDescription = newDescription; }//end setModelDescription: @@ -1078,9 +1075,6 @@ - (void) setModelDescription:(NSString *)newDescription //============================================================================== - (void) setFileName:(NSString *)newName { - [newName retain]; - [fileName release]; - fileName = newName; }//end setFileName: @@ -1097,8 +1091,6 @@ - (void) setAuthor:(NSString *)newAuthor // behavior in the inspector if (newAuthor == nil) newAuthor = @""; - [newAuthor retain]; - [author release]; author = newAuthor; @@ -1572,30 +1564,6 @@ - (void) registerUndoActions:(NSUndoManager *)undoManager }//end registerUndoActions: -#pragma mark - -#pragma mark DESTRUCTOR -#pragma mark - - -//========== dealloc =========================================================== -// -// Purpose: So I go to the pet store to buy a dog. And this guy sells me -// this puppy with three heads. Where in the world did he find a -// freak like that? So I says, "buddy, I want a normal dog." And -// the guy says, "Mister, where you're going, this dog *is* normal. -// Weird. -// -//============================================================================== -- (void) dealloc -{ - [modelDescription release]; - [fileName release]; - [author release]; - - [colorLibrary release]; - - [super dealloc]; - -}//end dealloc //- (void) invalCache:(CacheFlagsT) flags //{ diff --git a/trunk/Bricksmith/Source/LDraw/Files/LDrawStep.m b/trunk/Bricksmith/Source/LDraw/Files/LDrawStep.m index 837fdb1..a2f0bf9 100644 --- a/trunk/Bricksmith/Source/LDraw/Files/LDrawStep.m +++ b/trunk/Bricksmith/Source/LDraw/Files/LDrawStep.m @@ -55,7 +55,7 @@ + (id) emptyStep { LDrawStep *newStep = [[LDrawStep alloc] init]; - return [newStep autorelease]; + return newStep; }//end emptyStep @@ -85,7 +85,7 @@ + (id) emptyStepWithFlavor:(LDrawStepFlavorT) flavorType //============================================================================== - (id) init { - [super init]; + if (!(self = [super init])) return nil; stepRotationType = LDrawStepRotationNone; rotationAngle = ZeroPoint3; @@ -106,15 +106,19 @@ - (id) initWithLines:(NSArray *)lines inRange:(NSRange)range parentGroup:(dispatch_group_t)parentGroup { - NSString *currentLine = nil; - Class CommandClass = Nil; - NSRange commandRange = range; - id *directives = calloc(range.length, sizeof(LDrawDirective*)); - NSUInteger lineIndex = 0; - NSUInteger insertIndex = 0; + NSString *currentLine = nil; + Class CommandClass = Nil; + NSRange commandRange = range; + __strong LDrawDirective **directives = NULL; + NSUInteger lineIndex = 0; + NSUInteger insertIndex = 0; self = [super initWithLines:lines inRange:range parentGroup:parentGroup]; + // Creation a C array of retained pointers under ARC + // (see Transitioning to ARC Release Notes for details) + directives = (__strong LDrawDirective **)calloc(range.length, sizeof(LDrawDirective *)); + cachedBounds = InvalidBox; dispatch_group_t stepDispatchGroup = NULL; @@ -209,7 +213,9 @@ - (id) initWithLines:(NSArray *)lines currentDirective = directives[counter]; [self addDirective:currentDirective]; - [currentDirective release]; + + // Tell ARC to release the object + directives[counter] = nil; } free(directives); @@ -221,7 +227,6 @@ - (id) initWithLines:(NSArray *)lines dispatch_group_leave(parentGroup); } }); - dispatch_release(stepDispatchGroup); #endif return self; @@ -963,12 +968,10 @@ - (void) insertDirective:(LDrawDirective *)directive atIndex:(NSInteger)index - (void) removeDirectiveAtIndex:(NSInteger)index { [self invalCache:CacheFlagBounds|DisplayList]; - LDrawDirective *directive = [[[self subdirectives] objectAtIndex:index] retain]; + LDrawDirective *directive = [[self subdirectives] objectAtIndex:index]; [super removeDirectiveAtIndex:index]; - [directive release]; - }//end removeDirectiveAtIndex: @@ -1150,19 +1153,4 @@ - (void) registerUndoActions:(NSUndoManager *)undoManager }//end registerUndoActions: -#pragma mark - -#pragma mark DESTRUCTOR -#pragma mark - - -//========== dealloc =========================================================== -// -// Purpose: The Fat Lady has sung. -// -//============================================================================== -- (void) dealloc -{ - [super dealloc]; - -}//end dealloc - @end diff --git a/trunk/Bricksmith/Source/LDraw/Renderer/LDrawShaderRenderer.m b/trunk/Bricksmith/Source/LDraw/Renderer/LDrawShaderRenderer.m index 5202eab..d33f3ef 100644 --- a/trunk/Bricksmith/Source/LDraw/Renderer/LDrawShaderRenderer.m +++ b/trunk/Bricksmith/Source/LDraw/Renderer/LDrawShaderRenderer.m @@ -170,8 +170,6 @@ - (void) dealloc LDrawBDPDestroy(pool); - [super dealloc]; - }//end dealloc: diff --git a/trunk/Bricksmith/Source/LDraw/Support/ColorLibrary.m b/trunk/Bricksmith/Source/LDraw/Support/ColorLibrary.m index 9a361da..ab68ac9 100644 --- a/trunk/Bricksmith/Source/LDraw/Support/ColorLibrary.m +++ b/trunk/Bricksmith/Source/LDraw/Support/ColorLibrary.m @@ -23,6 +23,7 @@ #import "LDrawColor.h" #import "LDrawFile.h" #import "LDrawModel.h" +#import "LDrawMPDModel.h" #import "LDrawPaths.h" @implementation ColorLibrary @@ -56,7 +57,7 @@ + (ColorLibrary *) sharedColorLibrary // "Draw" it so that all the colors are recorded in the library [ldconfigFile draw:DRAW_NO_OPTIONS viewScale:1.0 parentColor:nil]; - sharedColorLibrary = [[[ldconfigFile activeModel] colorLibrary] retain]; + sharedColorLibrary = [[ldconfigFile activeModel] colorLibrary]; //---------- Special Colors -------------------------------------------- @@ -64,8 +65,8 @@ + (ColorLibrary *) sharedColorLibrary // context. But we still need to create entries for them in the library // so that they can be selected in the color palette. - LDrawColor *currentColor = [[[LDrawColor alloc] init] autorelease]; - LDrawColor *edgeColor = [[[LDrawColor alloc] init] autorelease]; + LDrawColor *currentColor = [[LDrawColor alloc] init]; + LDrawColor *edgeColor = [[LDrawColor alloc] init]; GLfloat currentColorRGBA[4] = {1.0, 1.0, 0.81, 1.0}; GLfloat edgeColorRGBA[4] = {0.75, 0.75, 0.75, 1.0}; @@ -302,22 +303,4 @@ void complimentColor(const GLfloat *originalColor, GLfloat *complimentColor) }//end complimentColor -#pragma mark - -#pragma mark DESTRUCTOR -#pragma mark - - -//========== dealloc =========================================================== -// -// Purpose: It's like the Blue Period. Depression and gloom abound as we -// consider the ultimate fate of being deallocated. -// -//============================================================================== -- (void) dealloc -{ - [colors release]; - - [super dealloc]; -} - - @end diff --git a/trunk/Bricksmith/Source/LDraw/Support/ComputationalGeometry.m b/trunk/Bricksmith/Source/LDraw/Support/ComputationalGeometry.m index 52e578f..b18506d 100644 --- a/trunk/Bricksmith/Source/LDraw/Support/ComputationalGeometry.m +++ b/trunk/Bricksmith/Source/LDraw/Support/ComputationalGeometry.m @@ -147,12 +147,12 @@ @implementation ComputationalGeometry +(NSArray *)tangentBetweenCircle:(NSMutableDictionary *)circle1 andCircle:(NSMutableDictionary *)circle2 { // Recast the supplied dictionaries as Circles for clarity in the main algorithm - Circle *c1 = [[[Circle alloc] initWithX:[[circle1 valueForKey:@"x"] integerValue] + Circle *c1 = [[Circle alloc] initWithX:[[circle1 valueForKey:@"x"] integerValue] Y:[[circle1 valueForKey:@"y"] integerValue] - R:[[circle1 valueForKey:@"r"] integerValue]] autorelease]; - Circle *c2 = [[[Circle alloc] initWithX:[[circle2 valueForKey:@"x"] integerValue] + R:[[circle1 valueForKey:@"r"] integerValue]]; + Circle *c2 = [[Circle alloc] initWithX:[[circle2 valueForKey:@"x"] integerValue] Y:[[circle2 valueForKey:@"y"] integerValue] - R:[[circle2 valueForKey:@"r"] integerValue]] autorelease]; + R:[[circle2 valueForKey:@"r"] integerValue]]; double d_sq = pow([c1 x] - [c2 x], 2) + pow([c1 y] - [c2 y], 2); if (d_sq <= pow([c1 r] - [c2 r], 2)) { @@ -357,4 +357,4 @@ +(int)leftmost:(NSMutableArray *)points return leftmost; } -@end \ No newline at end of file +@end diff --git a/trunk/Bricksmith/Source/LDraw/Support/FastSet.h b/trunk/Bricksmith/Source/LDraw/Support/FastSet.h new file mode 100644 index 0000000..a2fb72c --- /dev/null +++ b/trunk/Bricksmith/Source/LDraw/Support/FastSet.h @@ -0,0 +1,17 @@ +// +// FastSet.h +// Bricksmith +// +// Created by Sergey Slobodenyuk on 15.09.21. +// + +#import + +@interface FastSet : NSObject { +} + +- (void)addObject:(id)object; +- (void)removeObject:(id)object; +- (NSEnumerator *)objectEnumerator; + +@end diff --git a/trunk/Bricksmith/Source/LDraw/Support/FastSet.m b/trunk/Bricksmith/Source/LDraw/Support/FastSet.m new file mode 100644 index 0000000..3aad220 --- /dev/null +++ b/trunk/Bricksmith/Source/LDraw/Support/FastSet.m @@ -0,0 +1,85 @@ +// +// FastSet.m +// Bricksmith +// +// Created by Sergey Slobodenyuk on 15.09.21. +// + +/* + FastSet - THEORY OF OPERATION + + Here's the problem: the overhead of NS collections is relatively high, and attaching a + mutable set to each directive to keep track of who is observing it basically doubles + the number of NS containers and load time. + + Buuuuut - in nearly every important case, the nubmer of objects in a container is 1. + So the fast set structure optimizes away the NS mutable set for the simple cases where + we don't need a real set. + + ENCODING + + The fast set is an inner pointer which can contain either one object or an NSMutableSet + with more than one objects. + */ + +#import "FastSet.h" + +@interface FastSet () { + id data; +} + +@end + + +@implementation FastSet + +- (instancetype)init { + self = [super init]; + if (self) + { + data = nil; + } + return self; +} + + +- (void)addObject:(id)object { + NSValue *value = [NSValue valueWithPointer:(__bridge void *)(object)]; + if (data == nil) { + data = value; + } else if (![data isKindOfClass:[NSMutableSet class]]) { + NSMutableSet * newSet = [[NSMutableSet alloc] initWithCapacity:2]; + [newSet addObject:data]; + [newSet addObject:value]; + data = newSet; + } else { + [data addObject:value]; + } +} + +- (void)removeObject:(id)object { + NSValue *value = [NSValue valueWithPointer:(__bridge void *)(object)]; + if ([data isKindOfClass:[NSMutableSet class]]) { + assert([data containsObject:value]); + [data removeObject:value]; + if ([data count] == 1) { + data = [data anyObject]; + } + } else if ([data isEqualToValue:value]) { + data = nil; + } else { + assert(!"Removal of an unknown object."); + } +} + +- (NSEnumerator *)objectEnumerator { + if ([data isKindOfClass:[NSMutableSet class]]) { + return [data objectEnumerator]; + } else if (data != nil) { + return @[data].objectEnumerator; + } else { + return @[].objectEnumerator; + } +} + +@end diff --git a/trunk/Bricksmith/Source/LDraw/Support/LDrawDirective.h b/trunk/Bricksmith/Source/LDraw/Support/LDrawDirective.h index 05cfd76..0a3e54d 100644 --- a/trunk/Bricksmith/Source/LDraw/Support/LDrawDirective.h +++ b/trunk/Bricksmith/Source/LDraw/Support/LDrawDirective.h @@ -11,7 +11,7 @@ #import #import "MatrixMath.h" -#import "LDrawFastSet.h" +#import "FastSet.h" #import "LDrawRenderer.h" // This uses the hacky C wrapper around NSSet to improve performance. @@ -175,15 +175,15 @@ typedef void(^LDrawPartVisitor)(LDrawPart *); @interface LDrawDirective : NSObject { @private - LDrawContainer *enclosingDirective; //LDraw files are a hierarchy. + __weak LDrawContainer *enclosingDirective; //LDraw files are a hierarchy. #if NEW_SET - LDrawFastSet observers; + FastSet *observers; #else - NSMutableSet *observers; //Any observers watching us. This is an array of NSValues of pointers to create WEAK references. + NSMutableSet *observers; //Any observers watching us. This is an array of NSValues of pointers to create WEAK references. #endif - CacheFlagsT invalFlags; - BOOL isSelected; - NSString *iconName; + CacheFlagsT invalFlags; + BOOL isSelected; + NSString *iconName; } diff --git a/trunk/Bricksmith/Source/LDraw/Support/LDrawDirective.m b/trunk/Bricksmith/Source/LDraw/Support/LDrawDirective.m index b64c962..ba888eb 100644 --- a/trunk/Bricksmith/Source/LDraw/Support/LDrawDirective.m +++ b/trunk/Bricksmith/Source/LDraw/Support/LDrawDirective.m @@ -45,9 +45,9 @@ - (id) init iconName = @""; #if NEW_SET - LDrawFastSetInit(observers); + observers = [[FastSet alloc] init]; #else - observers = [[NSMutableArray alloc] init]; + observers = [[NSMutableSet alloc] init]; #endif return self; @@ -73,7 +73,6 @@ - (id) initWithLines:(NSArray *)lines #if USE_BLOCKS dispatch_group_wait(group, DISPATCH_TIME_FOREVER); - dispatch_release(group); #endif return directive; @@ -106,7 +105,6 @@ - (id) initWithLines:(NSArray *)lines if([lines count] == 0) { - [self autorelease]; self = nil; } @@ -128,7 +126,7 @@ - (id) initWithCoder:(NSCoder *)decoder self = [super init]; #if NEW_SET - LDrawFastSetInit(observers); + observers = [[FastSet alloc] init]; #else observers = [[NSMutableArray alloc] init]; #endif @@ -682,8 +680,6 @@ - (void) setSelected:(BOOL)flag //============================================================================== - (void) setIconName:(NSString *)icon { - [icon retain]; - [self->iconName release]; self->iconName = icon; }//end setIconName: @@ -814,7 +810,7 @@ - (void) registerUndoActions:(NSUndoManager *)undoManager - (void) addObserver:(id) observer { #if NEW_SET - LDrawFastSetInsert(observers, observer); + [observers addObject:observer]; #else if(observers == nil) printf("WARNING: OBSERVERS ARE NULL.\n"); @@ -833,8 +829,8 @@ - (void) addObserver:(id) observer - (void) removeObserver:(id) observer { #if NEW_SET - LDrawFastSetRemove(observers,observer); - #else + [observers removeObject:observer]; + #else if(observers == nil) printf("WARNING: OBSERVERS ARE NULL.\n"); //printf("directive %p told to lose observer %p.\n", self,observer); @@ -905,8 +901,11 @@ - (void) collectSelf:(id)renderer - (void) dealloc { #if NEW_SET - MESSAGE_FOR_SET(observers,LDrawObserver,observableSaysGoodbyeCruelWorld:self); - LDrawFastSetDealloc(observers); + for (NSValue * o in observers.objectEnumerator) + { + id oo = [o pointerValue]; + [oo observableSaysGoodbyeCruelWorld:self]; + } #else if(observers == nil) printf("WARNING: OBSERVERS ARE NULL.\n"); @@ -922,12 +921,9 @@ - (void) dealloc } } [observers release]; - observers = (id) 0xDEADBEEF; + observers = nil; #endif - - - [super dealloc]; //printf(" %p is clear.\n",self); } @@ -942,7 +938,11 @@ - (void) dealloc - (void) sendMessageToObservers:(MessageT) msg { #if NEW_SET - MESSAGE_FOR_SET(observers,LDrawObserver,receiveMessage:msg who:self); + for (NSValue * o in observers.objectEnumerator) + { + id oo = [o pointerValue]; + [oo receiveMessage:msg who:self]; + } #else NSSet * orig = [NSSet setWithSet:observers]; for (NSValue * o in orig) @@ -977,8 +977,12 @@ - (void) invalCache:(CacheFlagsT) flags invalFlags |= newFlags; #if NEW_SET - MESSAGE_FOR_SET(observers,LDrawObserver,statusInvalidated:newFlags who:self); - #else + for (NSValue * o in observers.objectEnumerator) + { + id oo = [o pointerValue]; + [oo statusInvalidated:newFlags who:self]; + } + #else NSSet * orig = [NSSet setWithSet:observers]; for (NSValue * o in orig) { diff --git a/trunk/Bricksmith/Source/LDraw/Support/LDrawDragHandle.m b/trunk/Bricksmith/Source/LDraw/Support/LDrawDragHandle.m index c4d3b2a..40baff2 100644 --- a/trunk/Bricksmith/Source/LDraw/Support/LDrawDragHandle.m +++ b/trunk/Bricksmith/Source/LDraw/Support/LDrawDragHandle.m @@ -390,19 +390,4 @@ + (void) makeSphereWithLongitudinalCount:(int)longitudeSections } -#pragma mark - -#pragma mark DESTRUCTOR -#pragma mark - - -//========== dealloc =========================================================== -// -// Purpose: Party like it's May 21, 2011! -// -//============================================================================== -- (void) dealloc -{ - [super dealloc]; -} - - @end diff --git a/trunk/Bricksmith/Source/LDraw/Support/LDrawFastSet.h b/trunk/Bricksmith/Source/LDraw/Support/LDrawFastSet.h deleted file mode 100644 index 1a2fff2..0000000 --- a/trunk/Bricksmith/Source/LDraw/Support/LDrawFastSet.h +++ /dev/null @@ -1,170 +0,0 @@ -/* - * LDrawFastSet.h - * Bricksmith - * - * Created by bsupnik on 9/15/12. - * Copyright 2012 __MyCompanyName__. All rights reserved. - * - */ - -/* - LDrawFastSet - THEORY OF OPERATION - - Here's the problem: the overhead of NS collections is relatively high, and attaching a - mutable set to each directive to keep track of who is observing it basically doubles - the number of NS containers and load time. - - Buuuuut - in nearly every important case, the nubmer of objects in a container is 1. - So the fast set structure optimizes away the NS mutable set for the simple cases where - we don't need a real set. - - ENCODING - - The fast set is a pair of pointers with the following encoding rules: - - p1 p2 meaning - NULL NULL The set is empty. - id1 NULL The set contains one object, refered to via id1. - id1 id2 The set contains two objects, referred to via id1 and id2. - NULL id2 The set contains at least 3 objects, contained in an NSMutableSet stored in id2. - -*/ - -typedef struct { - - union { - struct { - void * p1; - void * p2; - } ptr; - struct { - void * flag; - NSMutableSet * mutable_set; - } obj; - }; - -} LDrawFastSet; - - - - -#define MESSAGE_FOR_SET(this,ns_type,__msg) \ - do { \ - if(this.ptr.p1) \ - { \ - id p1 = this.ptr.p1; \ - id p2 = this.ptr.p2; \ - if(p1) [p1 __msg]; \ - if(p2 && LDrawFastSetContains(this, p2)) \ - [p2 __msg]; \ - } \ - else \ - { \ - if(this.ptr.p2) \ - { \ - NSSet * orig = [NSSet setWithSet:this.obj.mutable_set]; \ - for (NSValue * o in orig) \ - { \ - id oo = [o pointerValue]; \ - if(LDrawFastSetContains(this,oo)) \ - { \ - [oo __msg]; \ - } \ - } \ - } \ - } \ - } while(0) - -#define LDrawFastSetContains(this, p) \ - ((this.obj.flag == NULL && this.obj.mutable_set != nil) ? \ - ([this.obj.mutable_set containsObject:[NSValue valueWithPointer:p]] ? 1 : 0) : \ - ((this.ptr.p1 == p || this.ptr.p2 == p) ? 1 : 0)) - -#define LDrawFastSetInit(this) \ - do { \ - this.ptr.p1 = this.ptr.p2 = NULL; \ - } while(0) - - -#define LDrawFastSetDealloc(this) \ - do {\ - if(this.obj.flag == NULL && this.obj.mutable_set != nil) \ - [this.obj.mutable_set release]; \ - } while(0) - -#define LDrawFastSetInsert(this,p) \ - do {\ - if(this.ptr.p1) \ - { \ - if(this.ptr.p2) \ - { \ - if(p != this.ptr.p1 && p != this.ptr.p2) \ - { \ - NSMutableSet * new_set = [[NSMutableSet alloc] initWithCapacity:3]; \ - [new_set addObject:[NSValue valueWithPointer:this.ptr.p1]]; \ - [new_set addObject:[NSValue valueWithPointer:this.ptr.p2]]; \ - [new_set addObject:[NSValue valueWithPointer:p]]; \ - this.obj.flag = NULL; \ - this.obj.mutable_set = new_set; \ - } \ - } \ - else \ - { \ - if(p != this.ptr.p1) \ - this.ptr.p2 = p; \ - } \ - } \ - else \ - { \ - if(this.ptr.p2) \ - { \ - [this.obj.mutable_set addObject:[NSValue valueWithPointer:p]]; \ - } \ - else \ - { \ - this.ptr.p1 = p; \ - } \ - } \ - } while(0) - - -#define LDrawFastSetRemove(this, p) \ - do { \ - if(this.obj.flag == NULL && this.obj.mutable_set != nil) \ - { \ - NSValue * me = [NSValue valueWithPointer:p]; \ - assert([this.obj.mutable_set containsObject:me]); \ - [this.obj.mutable_set removeObject:me]; \ - assert([this.obj.mutable_set count] >= 2); \ - if([this.obj.mutable_set count] == 2) \ - { \ - void ** ptr = &this.ptr.p1; \ - NSMutableSet * dead = this.obj.mutable_set; \ - for(NSValue * o in dead) \ - { \ - *ptr = [o pointerValue]; \ - ++ptr; \ - } \ - [dead release]; \ - } \ - } \ - else \ - { \ - if(this.ptr.p1 == p) \ - { \ - this.ptr.p1 = this.ptr.p2; \ - this.ptr.p2 = NULL; \ - } \ - else if(this.ptr.p2 == p) \ - { \ - this.ptr.p2 = NULL; \ - } \ - else { \ - assert(!"Removal of an unknown object."); \ - } \ - } \ - } while(0) - - - - diff --git a/trunk/Bricksmith/Source/LDraw/Support/LDrawGLCamera.m b/trunk/Bricksmith/Source/LDraw/Support/LDrawGLCamera.m index d56332e..17b3ceb 100644 --- a/trunk/Bricksmith/Source/LDraw/Support/LDrawGLCamera.m +++ b/trunk/Bricksmith/Source/LDraw/Support/LDrawGLCamera.m @@ -25,7 +25,7 @@ @interface LDrawGLCamera () { - id scroller; + __weak id scroller; GLfloat projection[16]; GLfloat modelView[16]; @@ -81,18 +81,6 @@ - (id) init }//end init -//========== dealloc =========================================================== -/// -/// @abstract It's time to kick the bucket and go to meet the great head of -/// light entertainment in the sky. -/// -//============================================================================== -- (void) dealloc -{ - [super dealloc]; -}//end dealloc - - //========== setScroller: ====================================================== /// /// @abstract Specifies a scroller protocol that the camera uses to send diff --git a/trunk/Bricksmith/Source/LDraw/Support/LDrawGLRenderer.m b/trunk/Bricksmith/Source/LDraw/Support/LDrawGLRenderer.m index 25958a6..ee608e1 100644 --- a/trunk/Bricksmith/Source/LDraw/Support/LDrawGLRenderer.m +++ b/trunk/Bricksmith/Source/LDraw/Support/LDrawGLRenderer.m @@ -16,6 +16,8 @@ // more importantly, figures out what it *means*. The *meaning* is // what the renderer's methods care about. // +// Note: This file uses manual reference counting. +// // Created by Allen Smith on 4/17/05. // Copyright 2005. All rights reserved. //============================================================================== @@ -26,6 +28,7 @@ #import "LDrawDragHandle.h" #import "LDrawFile.h" #import "LDrawModel.h" +#import "LDrawMPDModel.h" #import "LDrawPart.h" #import "LDrawStep.h" #import "LDrawUtilities.h" diff --git a/trunk/Bricksmith/Source/LDraw/Support/LDrawPaths.m b/trunk/Bricksmith/Source/LDraw/Support/LDrawPaths.m index d1efb0b..0d5ad8c 100644 --- a/trunk/Bricksmith/Source/LDraw/Support/LDrawPaths.m +++ b/trunk/Bricksmith/Source/LDraw/Support/LDrawPaths.m @@ -87,8 +87,6 @@ - (NSString *) preferredLDrawPath //============================================================================== - (void) setPreferredLDrawPath:(NSString *)pathIn { - [pathIn retain]; - [self->preferredLDrawPath release]; self->preferredLDrawPath = pathIn; } @@ -179,7 +177,7 @@ - (NSString *) primitives48PathForDomain:(LDrawDomain)domain //============================================================================== - (NSString *) ldconfigPath { - NSFileManager *fileManager = [[[NSFileManager alloc] init] autorelease]; + NSFileManager *fileManager = [[NSFileManager alloc] init]; NSBundle *mainBundle = nil; NSString *installedPath = nil; NSString *builtInPath = nil; @@ -226,7 +224,7 @@ - (NSString *) ldconfigPath //============================================================================== - (NSString *) MLCadIniPath { - NSFileManager *fileManager = [[[NSFileManager alloc] init] autorelease]; + NSFileManager *fileManager = [[NSFileManager alloc] init]; NSString *preferredPath = [[self preferredLDrawPath] stringByAppendingPathComponent:MLCAD_INI_FILE_NAME]; NSString *actualPath = nil; @@ -383,7 +381,7 @@ - (NSString *) findLDrawPath //============================================================================== - (NSString *) pathForPartName:(NSString *)partName { - NSFileManager *fileManager = [[[NSFileManager alloc] init] autorelease]; + NSFileManager *fileManager = [[NSFileManager alloc] init]; static NSArray *searchPaths = nil; NSMutableString *fixedPartName = [NSMutableString stringWithString:partName]; NSString *partPath = nil; @@ -469,7 +467,7 @@ - (BOOL) validateLDrawFolder:(NSString *)folderPath NSString *partsFolderPath = [folderPath stringByAppendingPathComponent:PARTS_DIRECTORY_NAME]; NSString *primitivesFolderPath = [folderPath stringByAppendingPathComponent:PRIMITIVES_DIRECTORY_NAME]; - NSFileManager *fileManager = [[[NSFileManager alloc] init] autorelease]; + NSFileManager *fileManager = [[NSFileManager alloc] init]; BOOL folderIsValid = NO; if( [fileManager fileExistsAtPath:folderPath] diff --git a/trunk/Bricksmith/Source/LDraw/Support/LDrawUtilities.m b/trunk/Bricksmith/Source/LDraw/Support/LDrawUtilities.m index 479191f..0718498 100644 --- a/trunk/Bricksmith/Source/LDraw/Support/LDrawUtilities.m +++ b/trunk/Bricksmith/Source/LDraw/Support/LDrawUtilities.m @@ -81,8 +81,6 @@ + (void) setDefaultAuthor:(NSString *)nameIn // LLW: If the incoming nameIn is nil, leave this alone. if (nameIn != nil) { - [nameIn retain]; - [defaultAuthor release]; defaultAuthor = nameIn; } } @@ -216,7 +214,7 @@ + (LDrawColor *) parseColorFromField:(NSString *)colorField break; } - color = [[[LDrawColor alloc] init] autorelease]; + color = [[LDrawColor alloc] init]; [color setColorCode:LDrawColorCustomRGB]; [color setEdgeColorCode:LDrawBlack]; [color setColorRGBA:components]; @@ -230,7 +228,7 @@ + (LDrawColor *) parseColorFromField:(NSString *)colorField if(color == nil) { // This is probably a file-local color. Or a file from the future. - color = [[[LDrawColor alloc] init] autorelease]; + color = [[LDrawColor alloc] init]; [color setColorCode:colorCode]; [color setEdgeColorCode:LDrawBlack]; } @@ -389,7 +387,7 @@ + (NSString *) stringFromFileData:(NSData *)fileData encoding:NSMacOSRomanStringEncoding ]; } - return [fileString autorelease]; + return fileString; }//end stringFromFileData: @@ -528,11 +526,11 @@ + (void) registerHitForObject:(id)hitObject depth:(float)hitDepth creditObject:( // wrap the pointers. if(creditObject == nil) { - key = [NSValue valueWithPointer:hitObject]; + key = [NSValue valueWithPointer:(__bridge const void *)(hitObject)]; } else { - key = [NSValue valueWithPointer:creditObject]; + key = [NSValue valueWithPointer:(__bridge const void *)(creditObject)]; } existingRecord = [hits objectForKey:key]; @@ -571,11 +569,11 @@ + (void) registerHitForObject:(id)hitObject creditObject:(id)creditObject hits:( // wrap the pointers. if(creditObject == nil) { - key = [NSValue valueWithPointer:hitObject]; + key = [NSValue valueWithPointer:(__bridge const void *)(hitObject)]; } else { - key = [NSValue valueWithPointer:creditObject]; + key = [NSValue valueWithPointer:(__bridge const void *)(creditObject)]; } [hits addObject:key]; @@ -594,24 +592,9 @@ + (void) registerHitForObject:(id)hitObject creditObject:(id)creditObject hits:( //------------------------------------------------------------------------------ + (CGImageRef) imageAtPath:(NSString *)imagePath { - NSURL *fileURL = nil; - CGImageSourceRef imageSource = NULL; - CGImageRef image = NULL; - - if(imagePath) - { - fileURL = [NSURL fileURLWithPath:imagePath]; - - imageSource = CGImageSourceCreateWithURL( (CFURLRef)fileURL, NULL ); - if(imageSource != NULL) - { - image = CGImageSourceCreateImageAtIndex(imageSource, 0, NULL); - } - } - - if(imageSource) CFRelease(imageSource); + NSImage *image = [[NSImage alloc] initWithContentsOfFile:imagePath]; - return (CGImageRef)[(id)image autorelease]; + return [image CGImageForProposedRect:NULL context:nil hints:nil]; } diff --git a/trunk/Bricksmith/Source/LDraw/Support/ModelManager.m b/trunk/Bricksmith/Source/LDraw/Support/ModelManager.m index e221bbf..8076bcd 100644 --- a/trunk/Bricksmith/Source/LDraw/Support/ModelManager.m +++ b/trunk/Bricksmith/Source/LDraw/Support/ModelManager.m @@ -86,10 +86,10 @@ - (id) initWithFileName:(NSString *) inFileName parentDir:(NSString *) inParentD //NSLog(@"Init service table %p\n", self); self->file = inFile; - self->fileName = [inFileName retain]; - self->parentDirectory = [inParentDir retain]; + self->fileName = inFileName; + self->parentDirectory = inParentDir; - NSFileManager *fileManager = [[[NSFileManager alloc] init] autorelease]; + NSFileManager *fileManager = [[NSFileManager alloc] init]; NSArray *partNames = [fileManager contentsOfDirectoryAtPath:inParentDir error:NULL]; // Must use reference-style names. Peer file names are only cached for the @@ -130,15 +130,7 @@ - (void) dealloc } - [peerFileNames release]; - // When we nuke the trackedFiles we release our retain count on the - // LDrawFiles. - [trackedFiles release]; - [fileName release]; - [parentDirectory release]; - - //NSLog(@"%p Gone\n",self); - [super dealloc]; + //NSLog(@"%p Gone\n",self); } @@ -154,7 +146,7 @@ - (LDrawFile *) beginService:(NSString *) inPartialPath NSString * fullPath = [parentDirectory stringByAppendingPathComponent:inPartialPath]; fullPath = [fullPath stringByReplacingOccurrencesOfString:@"\\" withString:@"/"]; - NSFileManager * fileManager = [[[NSFileManager alloc] init] autorelease]; + NSFileManager * fileManager = [[NSFileManager alloc] init]; // Quick check whether the file is still there. if (![fileManager fileExistsAtPath:fullPath]) @@ -174,14 +166,11 @@ - (LDrawFile *) beginService:(NSString *) inPartialPath #if USE_BLOCKS dispatch_group_wait(group, DISPATCH_TIME_FOREVER); - dispatch_release(group); #endif if(parsedFile) { [parsedFile setPath:fullPath]; [trackedFiles setObject:parsedFile forKey:fullPath]; - [parsedFile release]; // Hash table tracked files retains the ONLY - // ref count - our "init" ref count gets tossed! // The model we just opened (to help the user's doc) might in turn refer to yet more // peer files, so recursively open service on it. The "internal" version won't freak @@ -258,31 +247,11 @@ - (id) init { self = [super init]; serviceTables = [[NSMutableDictionary alloc] init]; - dirChars = [[NSCharacterSet characterSetWithCharactersInString:@"\\/"] retain]; + dirChars = [NSCharacterSet characterSetWithCharactersInString:@"\\/"]; return self; } -//========== dealloc =========================================================== -// -// Purpose: This is the end...my beautiful friend...the end... -// -//============================================================================== -- (void) dealloc -{ - //NSLog(@"model mgr gone - why?\n"); -// for(NSValue * key in serviceTables) -// { -// LDrawFile * f = [key pointerValue]; -// [f release]; -// } - [serviceTables release]; - [dirChars release]; - [super dealloc]; -} - - - //========== documentSignIn:withFile =========================================== // // Purpose: Begin providing model-finding services for a new file. @@ -293,7 +262,7 @@ - (void) dealloc //============================================================================== - (void) documentSignIn:(NSString *) docPath withFile:(LDrawFile *) file { - if([serviceTables objectForKey:[NSValue valueWithPointer:file]] != nil) + if([serviceTables objectForKey:[NSValue valueWithPointer:(__bridge const void *)(file)]] != nil) return; //NSLog(@"Accepting sign-in of document %@ as file %p\n", docPath, file); @@ -329,8 +298,7 @@ - (void) documentSignIn:(NSString *) docPath withFile:(LDrawFile *) file } while(did_drop); ModelServiceTable * newTable = [[ModelServiceTable alloc] initWithFileName:docFileName parentDir:docParentDir file:file]; - [serviceTables setObject:newTable forKey:[NSValue valueWithPointer:file]]; - [newTable release]; + [serviceTables setObject:newTable forKey:[NSValue valueWithPointer:(__bridge const void *)(file)]]; }//end documentSignIn:withFile: @@ -344,7 +312,7 @@ - (void) documentSignIn:(NSString *) docPath withFile:(LDrawFile *) file //============================================================================== - (void) documentSignInInternal:(NSString *) docPath withFile:(LDrawFile *) file { - if([serviceTables objectForKey:[NSValue valueWithPointer:file]] != nil) + if([serviceTables objectForKey:[NSValue valueWithPointer:(__bridge const void *)(file)]] != nil) return; //NSLog(@"Accepting sign-in of document %@ as file %p\n", docPath, file); @@ -353,8 +321,7 @@ - (void) documentSignInInternal:(NSString *) docPath withFile:(LDrawFile *) file NSString * docFileName = [docPath lastPathComponent]; ModelServiceTable * newTable = [[ModelServiceTable alloc] initWithFileName:docFileName parentDir:docParentDir file:file]; - [serviceTables setObject:newTable forKey:[NSValue valueWithPointer:file]]; - [newTable release]; + [serviceTables setObject:newTable forKey:[NSValue valueWithPointer:(__bridge const void *)(file)]]; } @@ -367,38 +334,12 @@ - (void) documentSignInInternal:(NSString *) docPath withFile:(LDrawFile *) file //============================================================================== - (void) documentSignOut:(LDrawFile *) doc { - ModelServiceTable * t = [serviceTables objectForKey:[NSValue valueWithPointer:doc]]; + ModelServiceTable * t = [serviceTables objectForKey:[NSValue valueWithPointer:(__bridge const void *)(doc)]]; if(t) { //NSLog(@"Accepting sign-out for doc %p\n", doc); - // Ben says: the extra retain/release matter!! If we don't retain "t", then - // the ONLY strong reference to T comes frmo the servicesTables dictionary - // (the logical owner of all service tables) - removing the object at key - // releases the last ref and deletes the service table. - // - // Buuuuuuut! The dealloc method of the service table kills off sub-files by - // calling...wait for it...documentSignOut! The child will go and try to - // remove _its_ own services table. - // - // At this point we are calling removeObjectForKey on an object from INSIDE - // the callstack of removeObjectForKey on the same object. In other words, - // we're single threaded but still re-entrant. Is this okay? - // - // The answer seems to be: NO for 10.6.8 but MAYBE for 10.7 and later. - // NSMutableDictionary is Implemented via a CFMutableDictionary, and the code - // got a rework from 10.6.8 to 10.7.5. I haven't found any docs saying it's - // okay to re-entrantly remove keys, but the newer code looks like it could - // be plausibly safe - it sets all keys to nulls (recursive) first and then - // winds down the hash table. The old code mixed container mutation and - // callbacks, which seems dangerous. - // - // Either way we can MOOT the issue by simply retaining t. When we remove - // it from the dictionary, now WE own the last reference, and our release - // triggers the recursive-dealloc. This happens outside a CF container call. - [t retain]; - [serviceTables removeObjectForKey:[NSValue valueWithPointer:doc]]; - [t release]; + [serviceTables removeObjectForKey:[NSValue valueWithPointer:(__bridge const void *)(doc)]]; } } @@ -415,7 +356,7 @@ - (void) documentSignOut:(LDrawFile *) doc //============================================================================== - (LDrawModel *) requestModel:(NSString *) partName withDocument:(LDrawFile *) whoIsAsking { - ModelServiceTable * table = [serviceTables objectForKey:[NSValue valueWithPointer:whoIsAsking]]; + ModelServiceTable * table = [serviceTables objectForKey:[NSValue valueWithPointer:(__bridge const void *)(whoIsAsking)]]; if(table == nil) { //NSLog(@" ignoring part lookup on part %@ because file %p is unknown.\n", partName, whoIsAsking); diff --git a/trunk/Bricksmith/Source/LDraw/Support/PartCatalogBuilder.m b/trunk/Bricksmith/Source/LDraw/Support/PartCatalogBuilder.m index 75267ff..43f59d2 100644 --- a/trunk/Bricksmith/Source/LDraw/Support/PartCatalogBuilder.m +++ b/trunk/Bricksmith/Source/LDraw/Support/PartCatalogBuilder.m @@ -66,8 +66,8 @@ - (void) makePartCatalogWithMaxLoadCountHandler:(void (^)(NSUInteger maxPartCoun progressIncrementHandler:(void (^)())progressIncrementHandler completionHandler:(void (^)(NSDictionary *newCatalog))completionHandler { - NSFileManager *fileManager = [[[NSFileManager alloc] init] autorelease]; - LDrawPaths *paths = [[[LDrawPaths alloc] init] autorelease]; + NSFileManager *fileManager = [[NSFileManager alloc] init]; + LDrawPaths *paths = [[LDrawPaths alloc] init]; NSString *ldrawPath = [paths preferredLDrawPath]; NSMutableArray *searchPaths = [NSMutableArray array]; @@ -237,7 +237,7 @@ - (void) addPartsInFolder:(NSString *)folderPath namePrefix:(NSString *)namePrefix progressIncrementHandler:(void (^)())progressIncrementHandler { - NSFileManager *fileManager = [[[NSFileManager alloc] init] autorelease]; + NSFileManager *fileManager = [[NSFileManager alloc] init]; // Not working for some reason. Why? // NSArray *readableFileTypes = [NSDocument readableTypes]; // NSLog(@"readable types: %@", readableFileTypes); @@ -359,149 +359,148 @@ - (void) addPartsInFolder:(NSString *)folderPath //============================================================================== - (NSMutableDictionary *) catalogInfoForFileAtPath:(NSString *)filepath { - NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init]; + NSMutableDictionary *catalogInfo = nil; + + @autoreleasepool { - NSString *fileContents = [LDrawUtilities stringFromFile:filepath]; - NSCharacterSet *whitespace = [NSCharacterSet whitespaceAndNewlineCharacterSet]; - - NSString *partNumber = nil; - NSString *partDescription = nil; - NSString *category = nil; - NSMutableArray *keywords = nil; - - NSMutableDictionary *catalogInfo = nil; - - - // Read the first line of the file. Make sure the file is parsable. - if( fileContents != nil - && [fileContents length] > 0 ) - { - NSUInteger stringLength = [fileContents length]; - NSUInteger lineStartIndex = 0; - NSUInteger nextlineStartIndex = 0; - NSUInteger newlineIndex = 0; //index of the first newline character in the line. - NSInteger lineLength = 0; - NSString *line = nil; - NSString *lineCode = nil; - NSString *lineRemainder = nil; - NSString *implicitCategory = nil; + NSString *fileContents = [LDrawUtilities stringFromFile:filepath]; + NSCharacterSet *whitespace = [NSCharacterSet whitespaceAndNewlineCharacterSet]; - catalogInfo = [NSMutableDictionary dictionary]; + NSString *partNumber = nil; + NSString *partDescription = nil; + NSString *category = nil; + NSMutableArray *keywords = nil; - // Get the name of the part. - // We need a standard way to reference it; use lower-case to avoid any - // case-sensitivity issues. - partNumber = [[filepath lastPathComponent] lowercaseString]; - [catalogInfo setObject:partNumber forKey:PART_NUMBER_KEY]; - while(nextlineStartIndex < stringLength) + // Read the first line of the file. Make sure the file is parsable. + if( fileContents != nil + && [fileContents length] > 0 ) { - // LDraw uses DOS lineendings - [fileContents getLineStart: &lineStartIndex - end: &nextlineStartIndex - contentsEnd: &newlineIndex - forRange: NSMakeRange(nextlineStartIndex,1) ]; //that is, contains the first character. + NSUInteger stringLength = [fileContents length]; + NSUInteger lineStartIndex = 0; + NSUInteger nextlineStartIndex = 0; + NSUInteger newlineIndex = 0; //index of the first newline character in the line. + NSInteger lineLength = 0; + NSString *line = nil; + NSString *lineCode = nil; + NSString *lineRemainder = nil; + NSString *implicitCategory = nil; - lineLength = newlineIndex - lineStartIndex; - line = [fileContents substringWithRange:NSMakeRange(lineStartIndex, lineLength)]; - lineCode = [LDrawUtilities readNextField:line remainder:&lineRemainder ]; - - //Check to see if this is a valid LDraw header. - if(lineStartIndex == 0) - { - if([lineCode isEqualToString:@"0"] == NO) - break; - - partDescription = [lineRemainder stringByTrimmingCharactersInSet:whitespace]; - implicitCategory = [self categoryForDescription:partDescription]; - [catalogInfo setObject:partDescription forKey:PART_NAME_KEY]; - } - else if([lineCode isEqualToString:@"0"] == YES) + catalogInfo = [NSMutableDictionary dictionary]; + + // Get the name of the part. + // We need a standard way to reference it; use lower-case to avoid any + // case-sensitivity issues. + partNumber = [[filepath lastPathComponent] lowercaseString]; + [catalogInfo setObject:partNumber forKey:PART_NUMBER_KEY]; + + while(nextlineStartIndex < stringLength) { - // Try to find keywords or category - NSString *meta = [LDrawUtilities readNextField:lineRemainder remainder:&lineRemainder]; + // LDraw uses DOS lineendings + [fileContents getLineStart: &lineStartIndex + end: &nextlineStartIndex + contentsEnd: &newlineIndex + forRange: NSMakeRange(nextlineStartIndex,1) ]; //that is, contains the first character. - if([meta isEqualToString:LDRAW_CATEGORY]) + lineLength = newlineIndex - lineStartIndex; + line = [fileContents substringWithRange:NSMakeRange(lineStartIndex, lineLength)]; + lineCode = [LDrawUtilities readNextField:line remainder:&lineRemainder ]; + + //Check to see if this is a valid LDraw header. + if(lineStartIndex == 0) { - // Turns out !CATEGORY is not as reliable as it ought to be. - // In typical LDraw fashion, the feature was not have a - // simultaneous, universal deployment. Circa 2014, the only - // categories I deemed to be consistent and advantageous - // under the current system are the two-word categories that - // couldn't be represented under the old system. - // - // 2020 update: I am not going to fight !CATEGORY anymore. - // With one exception: Duplo parts should not be mixed in, - // and LDraw is making no attempt to separate them. So if - // the description begins with Duplo, I'm ignoring the - // !CATEGORY, which will cause implicitCategory (Duplo) to - // win. - // - // Also, allow the !LDRAW_ORG Part Alias to take precedence - // if it has already been found. - if( [implicitCategory hasPrefix:@"Duplo"] == NO - && [catalogInfo objectForKey:PART_CATEGORY_KEY] == nil ) - { - category = [lineRemainder stringByTrimmingCharactersInSet:whitespace]; - [catalogInfo setObject:category forKey:PART_CATEGORY_KEY]; - } + if([lineCode isEqualToString:@"0"] == NO) + break; + + partDescription = [lineRemainder stringByTrimmingCharactersInSet:whitespace]; + implicitCategory = [self categoryForDescription:partDescription]; + [catalogInfo setObject:partDescription forKey:PART_NAME_KEY]; } - else if([meta isEqualToString:LDRAW_KEYWORDS]) + else if([lineCode isEqualToString:@"0"] == YES) { - if(keywords == nil) + // Try to find keywords or category + NSString *meta = [LDrawUtilities readNextField:lineRemainder remainder:&lineRemainder]; + + if([meta isEqualToString:LDRAW_CATEGORY]) { - keywords = [NSMutableArray array]; - [catalogInfo setObject:keywords forKey:PART_KEYWORDS_KEY]; + // Turns out !CATEGORY is not as reliable as it ought to be. + // In typical LDraw fashion, the feature was not have a + // simultaneous, universal deployment. Circa 2014, the only + // categories I deemed to be consistent and advantageous + // under the current system are the two-word categories that + // couldn't be represented under the old system. + // + // 2020 update: I am not going to fight !CATEGORY anymore. + // With one exception: Duplo parts should not be mixed in, + // and LDraw is making no attempt to separate them. So if + // the description begins with Duplo, I'm ignoring the + // !CATEGORY, which will cause implicitCategory (Duplo) to + // win. + // + // Also, allow the !LDRAW_ORG Part Alias to take precedence + // if it has already been found. + if( [implicitCategory hasPrefix:@"Duplo"] == NO + && [catalogInfo objectForKey:PART_CATEGORY_KEY] == nil ) + { + category = [lineRemainder stringByTrimmingCharactersInSet:whitespace]; + [catalogInfo setObject:category forKey:PART_CATEGORY_KEY]; + } } - // Keywords can be multiline, so must add to any we've already collected! - NSArray *newKeywords = [lineRemainder componentsSeparatedByCharactersInSet:[NSCharacterSet characterSetWithCharactersInString:@","]]; - for(NSString *keyword in newKeywords) + else if([meta isEqualToString:LDRAW_KEYWORDS]) { - [keywords addObject:[keyword stringByTrimmingCharactersInSet:whitespace]]; + if(keywords == nil) + { + keywords = [NSMutableArray array]; + [catalogInfo setObject:keywords forKey:PART_KEYWORDS_KEY]; + } + // Keywords can be multiline, so must add to any we've already collected! + NSArray *newKeywords = [lineRemainder componentsSeparatedByCharactersInSet:[NSCharacterSet characterSetWithCharactersInString:@","]]; + for(NSString *keyword in newKeywords) + { + [keywords addObject:[keyword stringByTrimmingCharactersInSet:whitespace]]; + } } - } - else if([meta isEqualToString:LDRAW_ORG]) - { - // Force alias parts into a ghetto category which will keep - // them far away from normal building. - // !LDRAW_ORG: optional qualifier Alias can appear with Part/Shortcut/etc https://www.ldraw.org/article/398.html - if([lineRemainder ams_containsString:@"Alias" options:kNilOptions]) + else if([meta isEqualToString:LDRAW_ORG]) { - category = Category_Alias; - [catalogInfo setObject:category forKey:PART_CATEGORY_KEY]; + // Force alias parts into a ghetto category which will keep + // them far away from normal building. + // !LDRAW_ORG: optional qualifier Alias can appear with Part/Shortcut/etc https://www.ldraw.org/article/398.html + if([lineRemainder ams_containsString:@"Alias" options:kNilOptions]) + { + category = Category_Alias; + [catalogInfo setObject:category forKey:PART_CATEGORY_KEY]; + } } } + else if([lineCode length] == 0) + { + // line is blank. Skip. + } + else + { + // Non-comment, non-blank line. This cannot be part of the header. + break; + } } - else if([lineCode length] == 0) - { - // line is blank. Skip. - } - else + + // If no !CATEGORY directive, the the category is to be derived from the + // first word of the description. + if( [catalogInfo objectForKey:PART_NAME_KEY] + && [catalogInfo objectForKey:PART_CATEGORY_KEY] == nil) { - // Non-comment, non-blank line. This cannot be part of the header. - break; + partDescription = [catalogInfo objectForKey:PART_NAME_KEY]; + category = implicitCategory; + [catalogInfo setObject:category forKey:PART_CATEGORY_KEY]; } } - - // If no !CATEGORY directive, the the category is to be derived from the - // first word of the description. - if( [catalogInfo objectForKey:PART_NAME_KEY] - && [catalogInfo objectForKey:PART_CATEGORY_KEY] == nil) + else { - partDescription = [catalogInfo objectForKey:PART_NAME_KEY]; - category = implicitCategory; - [catalogInfo setObject:category forKey:PART_CATEGORY_KEY]; + NSLog(@"%@ is not a valid file", filepath); } + } - else - { - NSLog(@"%@ is not a valid file", filepath); - } - - [catalogInfo retain]; - [pool drain]; - return [catalogInfo autorelease]; + return catalogInfo; }//end catalogInfoForFileAtPath diff --git a/trunk/Bricksmith/Source/LDraw/Support/PartLibrary.m b/trunk/Bricksmith/Source/LDraw/Support/PartLibrary.m index b561d54..2225c49 100644 --- a/trunk/Bricksmith/Source/LDraw/Support/PartLibrary.m +++ b/trunk/Bricksmith/Source/LDraw/Support/PartLibrary.m @@ -102,9 +102,9 @@ - (id) init { self = [super init]; - loadedFiles = [[NSMutableDictionary dictionaryWithCapacity:400] retain]; + loadedFiles = [NSMutableDictionary dictionaryWithCapacity:400]; loadedImages = [[NSMutableDictionary alloc] init]; - optimizedRepresentations = [[NSMutableDictionary dictionaryWithCapacity:400] retain]; + optimizedRepresentations = [NSMutableDictionary dictionaryWithCapacity:400]; optimizedTextures = [[NSMutableDictionary alloc] init]; favorites = [[NSMutableArray alloc] init]; @@ -420,9 +420,6 @@ - (void) setFavorites:(NSArray *)favoritesIn //============================================================================== - (void) setPartCatalog:(NSDictionary *)newCatalog { - [newCatalog retain]; - [partCatalog release]; - partCatalog = newCatalog; //Inform any open parts browsers of the change. @@ -448,7 +445,7 @@ - (void) setPartCatalog:(NSDictionary *)newCatalog //============================================================================== - (BOOL) load { - NSFileManager *fileManager = [[[NSFileManager alloc] init] autorelease]; + NSFileManager *fileManager = [[NSFileManager alloc] init]; NSString *catalogPath = [[LDrawPaths sharedPaths] partCatalogPath]; BOOL partsListExists = NO; NSString *version = nil; @@ -507,7 +504,6 @@ - (void) reloadPartsWithMaxLoadCountHandler:(void (^)(NSUInteger maxPartCount))m [self setPartCatalog:newPartCatalog]; [[NSNotificationCenter defaultCenter] postNotificationName:LDrawPartLibraryReloaded object:self ]; } - [catalogBuilder release]; if(completionHandler) { @@ -596,7 +592,7 @@ - (void) loadImageForName:(NSString *)imageName BOOL alreadyParsing = NO; // another thread is already parsing partName // Already been parsed? - image = (CGImageRef)[self->loadedImages objectForKey:imageName]; + image = (__bridge CGImageRef)[self->loadedImages objectForKey:imageName]; if(image == nil) { #if USE_BLOCKS @@ -620,7 +616,7 @@ - (void) loadImageForName:(NSString *)imageName // until the parse is complete on whatever thread is actually // doing it. dispatch_group_enter(parentGroup); - [requestingGroups addObject:[NSValue valueWithPointer:parentGroup]]; + [requestingGroups addObject:[NSValue valueWithPointer:CFBridgingRetain(parentGroup)]]; #endif // Nobody has started parsing it yet, so we win! Parse from disk. @@ -642,7 +638,7 @@ - (void) loadImageForName:(NSString *)imageName ^{ if(image != nil) { - [self->loadedImages setObject:(id)image forKey:imageName]; + [self->loadedImages setObject:(__bridge id)image forKey:imageName]; } // Notify waiting threads we are finished parsing this part. @@ -661,7 +657,7 @@ - (void) loadImageForName:(NSString *)imageName image = (CGImageRef)[self readImageAtPath:imagePath asynchronously:NO completionHandler:NULL]; if(image != nil) { - [self->loadedImages setObject:(id)image forKey:imageName]; + [self->loadedImages setObject:(__bridge id)image forKey:imageName]; } #endif //----------------------------------------------------------------------- #if USE_BLOCKS @@ -720,7 +716,7 @@ - (void) loadModelForName:(NSString *)partName // until the parse is complete on whatever thread is actually // doing it. dispatch_group_enter(parentGroup); - [requestingGroups addObject:[NSValue valueWithPointer:parentGroup]]; + [requestingGroups addObject:[NSValue valueWithPointer:CFBridgingRetain(parentGroup)]]; #endif // Nobody has started parsing it yet, so we win! Parse from disk. @@ -783,7 +779,7 @@ - (CGImageRef) imageForTextureName:(NSString *)imageName NSString *imagePath = nil; // Has it already been parsed? - image = (CGImageRef)[self->loadedImages objectForKey:imageName]; + image = (__bridge CGImageRef)[self->loadedImages objectForKey:imageName]; if(image == nil) { @@ -792,7 +788,7 @@ - (CGImageRef) imageForTextureName:(NSString *)imageName image = [self readImageAtPath:imagePath asynchronously:NO completionHandler:NULL]; if(image != nil) - [self->loadedImages setObject:(id)image forKey:imageName]; + [self->loadedImages setObject:(__bridge id)image forKey:imageName]; } return image; @@ -850,7 +846,7 @@ - (CGImageRef) imageFromNeighboringFileForTexture:(LDrawTexture *)texture if(filePath != nil) { - fileManager = [[[NSFileManager alloc] init] autorelease]; + fileManager = [[NSFileManager alloc] init]; fileDirectory = [filePath stringByDeletingLastPathComponent]; imageName = [texture imageDisplayName]; // handle case-sensitive filesystem @@ -879,7 +875,7 @@ - (CGImageRef) imageFromNeighboringFileForTexture:(LDrawTexture *)texture { image = [self readImageAtPath:testPath asynchronously:NO completionHandler:NULL]; if(image != nil) - [self->loadedImages setObject:(id)image forKey:imageName]; + [self->loadedImages setObject:(__bridge id)image forKey:imageName]; } } @@ -1207,8 +1203,6 @@ - (CGImageRef) readImageAtPath:(NSString *)imagePath completionBlock(image); }); } - - dispatch_release(group); #endif return image; @@ -1261,7 +1255,7 @@ - (LDrawModel *) readModelAtPath:(NSString *)partPath dispatch_group_wait(group, DISPATCH_TIME_FOREVER); #endif [parsedFile optimizeStructure]; - model = [[[[parsedFile submodels] objectAtIndex:0] retain] autorelease]; + model = [[parsedFile submodels] objectAtIndex:0]; // We are "leaking" the enclosing file, but returning an internal model // without disconnecting it from its file is pretty dodgy and it would // be easy to code a bug in. We'd be better off returning the file @@ -1283,8 +1277,6 @@ - (LDrawModel *) readModelAtPath:(NSString *)partPath // [parsedFile release]; // see notes above }); } - - dispatch_release(group); #endif return model; @@ -1292,31 +1284,4 @@ - (LDrawModel *) readModelAtPath:(NSString *)partPath }//end readModelAtPath: -#pragma mark - -#pragma mark DESTRUCTOR -#pragma mark - - -//========== dealloc =========================================================== -// -// Purpose: We have turned a corner on the Circle of Life. -// -//============================================================================== -- (void) dealloc -{ - [partCatalog release]; - [favorites release]; - [loadedFiles release]; - [loadedImages release]; - [optimizedRepresentations release]; - [optimizedTextures release]; -#if USE_BLOCKS - dispatch_release(catalogAccessQueue); -#endif - [parsingGroups release]; - - [super dealloc]; - -}//end dealloc - - @end diff --git a/trunk/Bricksmith/Source/LDraw/Support/PartReport.m b/trunk/Bricksmith/Source/LDraw/Support/PartReport.m index 4b2c172..0f27731 100644 --- a/trunk/Bricksmith/Source/LDraw/Support/PartReport.m +++ b/trunk/Bricksmith/Source/LDraw/Support/PartReport.m @@ -54,7 +54,7 @@ + (PartReport *) partReportForContainer:(LDrawContainer *)container [partReport setLDrawContainer:container]; - return [partReport autorelease]; + return partReport; }//end partReportForContainer @@ -87,9 +87,6 @@ - (id) init //============================================================================== - (void) setLDrawContainer:(LDrawContainer *)newContainer { - [newContainer retain]; - [self->reportedObject release]; - self->reportedObject = newContainer; }//end setLDrawContainer: @@ -128,12 +125,6 @@ - (void) getMissingPiecesReport NSUInteger elementCount = [elements count]; NSUInteger counter = 0; - //clear out any previous reports. - if(self->missingParts != nil) - [missingParts release]; - if(self->movedParts != nil) - [movedParts release]; - self->missingParts = [[NSMutableArray alloc] init]; self->movedParts = [[NSMutableArray alloc] init]; @@ -392,24 +383,4 @@ - (NSString *) textualRepresentationWithSortDescriptors:(NSArray *)sortDescripto }//end textualRepresentationWithSortDescriptors: -#pragma mark - -#pragma mark DESTRUCTOR -#pragma mark - - -//========== dealloc =========================================================== -// -// Purpose: Quoth the Raven: "Nevermore!" -// -//============================================================================== -- (void) dealloc -{ - [reportedObject release]; - [partsReport release]; - [missingParts release]; - [movedParts release]; - - [super dealloc]; - -}//end dealloc - @end diff --git a/trunk/Bricksmith/Source/Other/BricksmithUtilities.m b/trunk/Bricksmith/Source/Other/BricksmithUtilities.m index 6d6af39..cd1ea8a 100644 --- a/trunk/Bricksmith/Source/Other/BricksmithUtilities.m +++ b/trunk/Bricksmith/Source/Other/BricksmithUtilities.m @@ -58,7 +58,7 @@ + (NSImage *) dragImageWithOffset:(NSPointPointer)dragImageOffset (*dragImageOffset).y -= (arrowSize.height/2 + [dragImage size].height/2); } - return [dragImage autorelease]; + return dragImage; }//end dragImageWithOffset: diff --git a/trunk/Bricksmith/Source/Other/MLCadIni.m b/trunk/Bricksmith/Source/Other/MLCadIni.m index 890c960..f12ee48 100644 --- a/trunk/Bricksmith/Source/Other/MLCadIni.m +++ b/trunk/Bricksmith/Source/Other/MLCadIni.m @@ -440,7 +440,7 @@ - (void) parseFromPath:(NSString *) path //---------- Parse LSynth Section ------------------------------------------ sectionLines = [sections objectForKey:MLCAD_SECTION_LSYNTH]; - self->lsynthVisibleTypes = [[self lsynthTypesFromLines:sectionLines] retain]; + self->lsynthVisibleTypes = [self lsynthTypesFromLines:sectionLines]; }//end parseFromPath: @@ -631,7 +631,7 @@ - (NSArray *) partsFromMinifigureLines:(NSArray *)lines // In any event, we want to discard these non-entries. if(gotName == YES) { - currentPart = [[[LDrawPart alloc] init] autorelease]; + currentPart = [[LDrawPart alloc] init]; [currentPart setTransformationMatrix:&transformation]; [currentPart setDisplayName:partName parse:NO inGroup:NULL]; @@ -655,7 +655,7 @@ - (NSArray *) partsFromMinifigureLines:(NSArray *)lines //---------- Sort list by part name ---------------------------------------- - NSSortDescriptor *sortDescriptor = [[[NSSortDescriptor alloc] initWithKey:@"browsingDescription" ascending:YES] autorelease]; + NSSortDescriptor *sortDescriptor = [[NSSortDescriptor alloc] initWithKey:@"browsingDescription" ascending:YES]; [parts sortUsingDescriptors:[NSArray arrayWithObject:sortDescriptor]]; return parts; diff --git a/trunk/Bricksmith/Source/Other/Mac LDraw_Prefix.pch b/trunk/Bricksmith/Source/Other/Mac LDraw_Prefix.pch index 9871cce..a3afd19 100644 --- a/trunk/Bricksmith/Source/Other/Mac LDraw_Prefix.pch +++ b/trunk/Bricksmith/Source/Other/Mac LDraw_Prefix.pch @@ -30,11 +30,6 @@ //#define USE_BLOCKS NS_BLOCKS_AVAILABLE #define USE_BLOCKS 0 -#if !USE_BLOCKS - #define dispatch_queue_t void * - #define dispatch_group_t void * -#endif - #ifndef OPEN_GL_HEADER #define OPEN_GL_HEADER #define OPEN_GL_EXT_HEADER diff --git a/trunk/Bricksmith/Source/Other/RegexKitLite.m b/trunk/Bricksmith/Source/Other/RegexKitLite.m index f938df2..6376037 100644 --- a/trunk/Bricksmith/Source/Other/RegexKitLite.m +++ b/trunk/Bricksmith/Source/Other/RegexKitLite.m @@ -3,6 +3,8 @@ // http://regexkit.sourceforge.net/ // Licensed under the terms of the BSD License, as specified below. // +// Note: This file uses manual reference counting. +// /* Copyright (c) 2008-2010, John Engelhart diff --git a/trunk/Bricksmith/Source/Widgets/BackgroundColorView.m b/trunk/Bricksmith/Source/Widgets/BackgroundColorView.m index 62a80a2..7a9a3fb 100644 --- a/trunk/Bricksmith/Source/Widgets/BackgroundColorView.m +++ b/trunk/Bricksmith/Source/Widgets/BackgroundColorView.m @@ -41,9 +41,6 @@ - (id) initWithFrame:(NSRect)frame //============================================================================== - (void) setBackgroundColor:(NSColor *)colorIn { - [colorIn retain]; - [self->backgroundColor release]; - self->backgroundColor = colorIn; }//end setBackgroundColor: @@ -62,21 +59,4 @@ - (void)drawRect:(NSRect)rect }//end drawRect: -#pragma mark - -#pragma mark DESTRUCTOR -#pragma mark - - -//========== dealloc =========================================================== -// -// Purpose: Turning a shade of blue. -// -//============================================================================== -- (void) dealloc -{ - [self->backgroundColor release]; - - [super dealloc]; - -}//end dealloc - @end diff --git a/trunk/Bricksmith/Source/Widgets/DialogPanel.m b/trunk/Bricksmith/Source/Widgets/DialogPanel.m index 102fa1e..50817ab 100644 --- a/trunk/Bricksmith/Source/Widgets/DialogPanel.m +++ b/trunk/Bricksmith/Source/Widgets/DialogPanel.m @@ -45,7 +45,6 @@ - (id) init //this takes the place of calling [super init] // Note that connections in the Nib file must be made // to the PieceCountPanel, not to the File's Owner! - [self autorelease]; return dialogPanel; @@ -96,22 +95,4 @@ - (IBAction) okButtonClicked:(id)sender }//end okButtonClicked: -#pragma mark - -#pragma mark DESTRUCTOR -#pragma mark - - -//========== dealloc =========================================================== -// -// Purpose: Our goose is cooked. -// -//============================================================================== -- (void) dealloc -{ - [objectController release]; - - [super dealloc]; - -}//end dealloc - - @end diff --git a/trunk/Bricksmith/Source/Widgets/ExtendedSplitView.m b/trunk/Bricksmith/Source/Widgets/ExtendedSplitView.m index cc647b3..4cc78c3 100644 --- a/trunk/Bricksmith/Source/Widgets/ExtendedSplitView.m +++ b/trunk/Bricksmith/Source/Widgets/ExtendedSplitView.m @@ -54,9 +54,6 @@ - (void) setAutosaveName:(NSString *)newName [super setAutosaveName:newName]; else { - [newName retain]; - [self->autosaveName release]; - autosaveName = newName; // Automatically restore. This is what Apple is doing in Leopard. @@ -259,8 +256,6 @@ - (void) dealloc { [[NSNotificationCenter defaultCenter] removeObserver:self]; - [super dealloc]; - }//end dealloc @end diff --git a/trunk/Bricksmith/Source/Widgets/FocusRingView.h b/trunk/Bricksmith/Source/Widgets/FocusRingView.h index 316ff71..0265309 100644 --- a/trunk/Bricksmith/Source/Widgets/FocusRingView.h +++ b/trunk/Bricksmith/Source/Widgets/FocusRingView.h @@ -18,7 +18,7 @@ //////////////////////////////////////////////////////////////////////////////// @interface FocusRingView : NSView { - NSView *focusSource; // the view which, if in focus, prompts us to draw a focus ring. + __weak NSView *focusSource; // the view which, if in focus, prompts us to draw a focus ring. } - (void) setFocusSource:(NSView *)newObject; diff --git a/trunk/Bricksmith/Source/Widgets/FocusRingView.m b/trunk/Bricksmith/Source/Widgets/FocusRingView.m index b55e229..6d75170 100644 --- a/trunk/Bricksmith/Source/Widgets/FocusRingView.m +++ b/trunk/Bricksmith/Source/Widgets/FocusRingView.m @@ -116,19 +116,4 @@ - (NSView *) hitTest:(NSPoint)aPoint }//end hitTest: -#pragma mark - -#pragma mark DESTRUCTOR -#pragma mark - - -//========== dealloc =========================================================== -// -// Purpose: Out of focus. -// -//============================================================================== -- (void) dealloc -{ - [super dealloc]; -} - - @end diff --git a/trunk/Bricksmith/Source/Widgets/IconTextCell.m b/trunk/Bricksmith/Source/Widgets/IconTextCell.m index bcf3978..05b01c4 100644 --- a/trunk/Bricksmith/Source/Widgets/IconTextCell.m +++ b/trunk/Bricksmith/Source/Widgets/IconTextCell.m @@ -64,7 +64,7 @@ - (id) copyWithZone:(NSZone *)zone //The pitfall is that it releases it too. So we have to retain our // instance variables here. - cell->image = [image retain]; + cell->image = image; return cell; @@ -281,8 +281,6 @@ - (BOOL) verticallyCentersTitle //============================================================================== - (void) setImage:(NSImage *)newImage { - [newImage retain]; - [image release]; image = newImage; }//end setImage: @@ -319,18 +317,4 @@ - (void) setVerticallyCentersTitle:(BOOL)flag } -#pragma mark - -#pragma mark DESTRUCTOR -#pragma mark - - -//========== dealloc =========================================================== -//============================================================================== -- (void) dealloc -{ - [image release]; - [super dealloc]; - -}//end dealloc - - @end diff --git a/trunk/Bricksmith/Source/Widgets/LDrawColorBar.m b/trunk/Bricksmith/Source/Widgets/LDrawColorBar.m index 3e2ab12..636fcf5 100644 --- a/trunk/Bricksmith/Source/Widgets/LDrawColorBar.m +++ b/trunk/Bricksmith/Source/Widgets/LDrawColorBar.m @@ -17,6 +17,23 @@ @implementation LDrawColorBar +//========== initWithCoder: ==================================================== +/// +/// @abstract Designated initializer +/// +//============================================================================== +- (instancetype)initWithFrame:(NSRect)frame +{ + self = [super initWithFrame:frame]; + if (self) { + // fix macOS 14 issue with default value = NO + // it looks like the entire window is filled with some color + self.clipsToBounds = YES; + } + return self; +} + + //========== drawRect: ========================================================= // // Purpose: Paints the represented color inside the bar, along with a small @@ -74,18 +91,15 @@ - (void) setLDrawColor:(LDrawColor *) newColor GLfloat components[4]; // assign ivar - [newColor retain]; - [self->color release]; self->color = newColor; // Set cached NSColor too [newColor getColorRGBA:components]; - [self->nsColor release]; - self->nsColor = [[NSColor colorWithCalibratedRed:components[0] - green:components[1] - blue:components[2] - alpha:1.0 ] retain]; + self->nsColor = [NSColor colorWithCalibratedRed:components[0] + green:components[1] + blue:components[2] + alpha:1.0 ]; //Create a tool tip to identify the LDraw color code. description = [newColor localizedName]; @@ -96,22 +110,4 @@ - (void) setLDrawColor:(LDrawColor *) newColor }//end setLDrawColor: -#pragma mark - -#pragma mark DESTRUCTOR -#pragma mark - - -//========== dealloc =========================================================== -// -// Purpose: Entering the long dark night. -// -//============================================================================== -- (void) dealloc -{ - [self->nsColor release]; - - [super dealloc]; - -}//end dealloc - - @end diff --git a/trunk/Bricksmith/Source/Widgets/LDrawColorWell.m b/trunk/Bricksmith/Source/Widgets/LDrawColorWell.m index dfb1be4..7f7e21c 100644 --- a/trunk/Bricksmith/Source/Widgets/LDrawColorWell.m +++ b/trunk/Bricksmith/Source/Widgets/LDrawColorWell.m @@ -33,6 +33,23 @@ @implementation LDrawColorWell static LDrawColorWell *sharedActiveColorWell = nil; +//========== initWithCoder: ==================================================== +/// +/// @abstract Called by objects in a Nib file. +/// +//============================================================================== +- (instancetype)initWithCoder:(NSCoder *)coder +{ + self = [super initWithCoder:coder]; + if (self) { + // fix macOS 14 issue with default value = NO + // it looks like the entire window is filled with some color + self.clipsToBounds = YES; + } + return self; +} + + #pragma mark - #pragma mark ACTIVE COLOR WELL #pragma mark - @@ -67,8 +84,6 @@ + (void) setActiveColorWell:(LDrawColorWell *)newWell [newWell setState:NSOnState]; //trade out variable - [newWell retain]; - [sharedActiveColorWell release]; sharedActiveColorWell = newWell; @@ -110,18 +125,15 @@ - (void) setLDrawColor:(LDrawColor *)newColor GLfloat components[4]; // assign ivar - [newColor retain]; - [self->color release]; self->color = newColor; // Set cached NSColor too [newColor getColorRGBA:components]; - [self->nsColor release]; - self->nsColor = [[NSColor colorWithCalibratedRed:components[0] - green:components[1] - blue:components[2] - alpha:1.0 ] retain]; + self->nsColor = [NSColor colorWithCalibratedRed:components[0] + green:components[1] + blue:components[2] + alpha:1.0 ]; [self setNeedsDisplay:YES]; @@ -256,10 +268,6 @@ - (void) dealloc if([LDrawColorWell activeColorWell] == self) [LDrawColorWell setActiveColorWell:nil]; - [self->nsColor release]; - - [super dealloc]; - }//end dealloc @end diff --git a/trunk/Bricksmith/Source/Widgets/LDrawGLView.h b/trunk/Bricksmith/Source/Widgets/LDrawGLView.h index 4dce679..d4f1b8f 100644 --- a/trunk/Bricksmith/Source/Widgets/LDrawGLView.h +++ b/trunk/Bricksmith/Source/Widgets/LDrawGLView.h @@ -40,12 +40,12 @@ // calls must pass through the LDrawOpenGLView first. LDrawGLRenderer *renderer; - FocusRingView *focusRingView; + FocusRingView *focusRingView; - IBOutlet id delegate; - id target; - SEL backAction; - SEL forwardAction; + __weak IBOutlet id delegate; + __weak id target; + SEL backAction; + SEL forwardAction; SEL nudgeAction; BOOL acceptsFirstResponder; // YES if we can become key @@ -62,7 +62,7 @@ Vector3 nudgeVector; // direction of nudge action (valid only in nudgeAction callback) } -- (void) internalInit; +- (void) setFocusRingVisible:(BOOL)isVisible; // Drawing - (void) draw; diff --git a/trunk/Bricksmith/Source/Widgets/LDrawGLView.m b/trunk/Bricksmith/Source/Widgets/LDrawGLView.m index d1d2be7..82015d0 100644 --- a/trunk/Bricksmith/Source/Widgets/LDrawGLView.m +++ b/trunk/Bricksmith/Source/Widgets/LDrawGLView.m @@ -109,7 +109,7 @@ - (void) internalInit // Yes, we have a nib file. Don't laugh. This view has accessories. [NSBundle loadNibNamed:@"LDrawGLViewAccessories" owner:self]; - self->focusRingView = [[[FocusRingView alloc] initWithFrame:[self bounds]] autorelease]; + self->focusRingView = [[FocusRingView alloc] initWithFrame:[self bounds]]; [focusRingView setAutoresizingMask:(NSViewWidthSizable | NSViewHeightSizable)]; [focusRingView setFocusSource:self]; @@ -179,11 +179,32 @@ - (void) internalInit owner:self userInfo:nil]; [self addTrackingArea:trackingArea]; - [trackingArea release]; }//end internalInit +//========== setFocusRingVisible: ============================================== +/// +/// @abstract Setup the focus ring view. +/// +/// @discussion In Minifigure Generator the focus ring view prevents that window +/// to deinitialize correctly (macOS 14 issue). On the other hand +/// there is only one GLView in that window, so we don't need to +/// have focus ring there. +/// Why we have this extra method? +/// Bec we set view property in Interface Builder, it is visible only +/// after initialization. +/// +//============================================================================== +- (void) setFocusRingVisible:(BOOL)isVisible +{ + if (!isVisible) { + [focusRingView setFocusSource:nil]; + [self removeOverlayView:focusRingView]; + } +} + + //========== prepareOpenGL ===================================================== // // Purpose: The context is all set up; this is where we prepare our OpenGL @@ -549,8 +570,6 @@ - (void) setAcceptsFirstResponder:(BOOL)flag //============================================================================== - (void) setAutosaveName:(NSString *)newName { - [newName retain]; - [self->autosaveName release]; self->autosaveName = newName; }//end setAutosaveName: @@ -1088,8 +1107,8 @@ - (void) resetCursorRects cursorImage = [NSImage imageNamed:@"Crosshair"]; break; } - cursor = [[[NSCursor alloc] initWithImage:cursorImage - hotSpot:NSMakePoint(8, 8)] autorelease]; + cursor = [[NSCursor alloc] initWithImage:cursorImage + hotSpot:NSMakePoint(8, 8)]; } else cursor = [NSCursor arrowCursor]; @@ -1106,8 +1125,8 @@ - (void) resetCursorRects if([self->renderer isTrackingDrag] == YES) { cursorImage = [NSImage imageNamed:@"ZoomCursor"]; - cursor = [[[NSCursor alloc] initWithImage:cursorImage - hotSpot:NSMakePoint(7, 10)] autorelease]; + cursor = [[NSCursor alloc] initWithImage:cursorImage + hotSpot:NSMakePoint(7, 10)]; } else cursor = [NSCursor crosshairCursor]; @@ -1115,20 +1134,20 @@ - (void) resetCursorRects case ZoomInTool: cursorImage = [NSImage imageNamed:@"ZoomInCursor"]; - cursor = [[[NSCursor alloc] initWithImage:cursorImage - hotSpot:NSMakePoint(7, 10)] autorelease]; + cursor = [[NSCursor alloc] initWithImage:cursorImage + hotSpot:NSMakePoint(7, 10)]; break; case ZoomOutTool: cursorImage = [NSImage imageNamed:@"ZoomOutCursor"]; - cursor = [[[NSCursor alloc] initWithImage:cursorImage - hotSpot:NSMakePoint(7, 10)] autorelease]; + cursor = [[NSCursor alloc] initWithImage:cursorImage + hotSpot:NSMakePoint(7, 10)]; break; case SpinTool: cursorImage = [NSImage imageNamed:@"Spin"]; - cursor = [[[NSCursor alloc] initWithImage:cursorImage - hotSpot:NSMakePoint(7, 10)] autorelease]; + cursor = [[NSCursor alloc] initWithImage:cursorImage + hotSpot:NSMakePoint(7, 10)]; break; case EraserTool: @@ -3012,7 +3031,7 @@ - (void) saveImageToPath:(NSString *)path NSAssert( image != NULL, @"CGBitmapContextCreate failure"); // Save the image to the file - dest = CGImageDestinationCreateWithURL((CFURLRef)[NSURL fileURLWithPath:path], CFSTR("public.tiff"), 1, nil); + dest = CGImageDestinationCreateWithURL((__bridge CFURLRef)[NSURL fileURLWithPath:path], CFSTR("public.tiff"), 1, nil); NSAssert( dest != 0, @"CGImageDestinationCreateWithURL failed"); // Set the image in the image destination to be `image' with @@ -3153,11 +3172,7 @@ - (void) dealloc [[NSNotificationCenter defaultCenter] removeObserver:self]; - [renderer release]; - [autosaveName release]; [focusRingView setFocusSource:nil]; - - [super dealloc]; }//end dealloc diff --git a/trunk/Bricksmith/Source/Widgets/LDrawViewerContainer.h b/trunk/Bricksmith/Source/Widgets/LDrawViewerContainer.h index 8e9c4a9..d0e1654 100644 --- a/trunk/Bricksmith/Source/Widgets/LDrawViewerContainer.h +++ b/trunk/Bricksmith/Source/Widgets/LDrawViewerContainer.h @@ -25,8 +25,8 @@ NS_ASSUME_NONNULL_BEGIN //------------------------------------------------------------------------------ @interface LDrawViewerContainer : NSView -@property (nonatomic, readonly) LDrawGLView* glView; -@property (nonatomic, assign) BOOL showsScrollbars; +@property (nonatomic, weak, readonly) LDrawGLView* glView; +@property (nonatomic) BOOL showsScrollbars; - (void) setVerticalPlacard:(NSView *)placardView; - (void) reflectLogicalDocumentRect:(Box2)newDocumentRect visibleRect:(Box2)visibleRect; diff --git a/trunk/Bricksmith/Source/Widgets/LDrawViewerContainer.m b/trunk/Bricksmith/Source/Widgets/LDrawViewerContainer.m index 53f756e..07670bf 100644 --- a/trunk/Bricksmith/Source/Widgets/LDrawViewerContainer.m +++ b/trunk/Bricksmith/Source/Widgets/LDrawViewerContainer.m @@ -11,11 +11,11 @@ @interface LDrawViewerContainer () -@property (nonatomic, unsafe_unretained) LDrawGLView* glView; -@property (nonatomic, strong) NSView* verticalPlacard; +@property (nonatomic, weak) LDrawGLView* glView; +@property (nonatomic, weak) NSView* verticalPlacard; -@property (nonatomic, unsafe_unretained) NSScroller* horizontalScroller; -@property (nonatomic, unsafe_unretained) NSScroller* verticalScroller; +@property (nonatomic, weak) NSScroller* horizontalScroller; +@property (nonatomic, weak) NSScroller* verticalScroller; @property (nonatomic, assign) Box2 documentRect; @property (nonatomic, assign) Box2 scrollVisibleRect; @@ -34,11 +34,10 @@ - (instancetype) initWithFrame:(NSRect)frameRect { self = [super initWithFrame:frameRect]; - _glView = [[LDrawGLView alloc] initWithFrame:self.bounds]; + LDrawGLView *glView = [[LDrawGLView alloc] initWithFrame:self.bounds]; + _glView = glView; [self addSubview:_glView]; - [_glView release]; - return self; } @@ -57,7 +56,8 @@ - (void) setShowsScrollbars:(BOOL)showsScrollbars if(showsScrollbars) { - _horizontalScroller = [[NSScroller alloc] initWithFrame:NSMakeRect(0, 0, 50, [NSScroller scrollerWidthForControlSize:NSControlSizeSmall scrollerStyle:NSScrollerStyleLegacy])]; + NSScroller *scroller = [[NSScroller alloc] initWithFrame:NSMakeRect(0, 0, 50, [NSScroller scrollerWidthForControlSize:NSControlSizeSmall scrollerStyle:NSScrollerStyleLegacy])]; + _horizontalScroller = scroller; _horizontalScroller.scrollerStyle = NSScrollerStyleLegacy; _horizontalScroller.controlSize = NSControlSizeSmall; _horizontalScroller.enabled = YES; @@ -65,16 +65,14 @@ - (void) setShowsScrollbars:(BOOL)showsScrollbars _horizontalScroller.action = @selector(scrollerDidChange:); [self addSubview:_horizontalScroller]; - _verticalScroller = [[NSScroller alloc] initWithFrame:NSMakeRect(0, 0, [NSScroller scrollerWidthForControlSize:NSControlSizeSmall scrollerStyle:NSScrollerStyleLegacy], 50)]; + scroller = [[NSScroller alloc] initWithFrame:NSMakeRect(0, 0, [NSScroller scrollerWidthForControlSize:NSControlSizeSmall scrollerStyle:NSScrollerStyleLegacy], 50)]; + _verticalScroller = scroller; _verticalScroller.scrollerStyle = NSScrollerStyleLegacy; _verticalScroller.controlSize = NSControlSizeSmall; _verticalScroller.enabled = YES; _verticalScroller.target = self; _verticalScroller.action = @selector(scrollerDidChange:); [self addSubview:_verticalScroller]; - - [_horizontalScroller release]; - [_verticalScroller release]; } else { @@ -96,10 +94,7 @@ - (void) setShowsScrollbars:(BOOL)showsScrollbars //============================================================================== - (void) setVerticalPlacard:(NSView *)newPlacard { - [newPlacard retain]; - [_verticalPlacard removeFromSuperview]; - [_verticalPlacard release]; _verticalPlacard = newPlacard; @@ -160,6 +155,8 @@ - (void) layout } _glView.frame = viewerFrame; + + [_glView setFocusRingVisible:self.focusRingType != NSFocusRingTypeNone]; } diff --git a/trunk/Bricksmith/Source/Widgets/OverlayHelperView.m b/trunk/Bricksmith/Source/Widgets/OverlayHelperView.m index 15d793b..6072be6 100644 --- a/trunk/Bricksmith/Source/Widgets/OverlayHelperView.m +++ b/trunk/Bricksmith/Source/Widgets/OverlayHelperView.m @@ -118,24 +118,6 @@ - (void) viewWillMoveToSuperview:(NSView *)newSuperview }//end viewWillMoveToSuperview: -#pragma mark - -#pragma mark DESTRUCTOR -#pragma mark - - -//========== dealloc =========================================================== -// -// Purpose: We are of help no more. -// -//============================================================================== -- (void) dealloc -{ - [helperWindow release]; - - [super dealloc]; - -}//end dealloc - - @end diff --git a/trunk/Bricksmith/Source/Widgets/OverlayHelperWindow.h b/trunk/Bricksmith/Source/Widgets/OverlayHelperWindow.h index 7296119..7532203 100644 --- a/trunk/Bricksmith/Source/Widgets/OverlayHelperWindow.h +++ b/trunk/Bricksmith/Source/Widgets/OverlayHelperWindow.h @@ -18,7 +18,7 @@ //////////////////////////////////////////////////////////////////////////////// @interface OverlayHelperWindow : NSWindow { - NSView *parentView; + __weak NSView *parentView; NSWindowOrderingMode order; } diff --git a/trunk/Bricksmith/Source/Widgets/OverlayHelperWindow.m b/trunk/Bricksmith/Source/Widgets/OverlayHelperWindow.m index 7ebfd9b..96c4f95 100644 --- a/trunk/Bricksmith/Source/Widgets/OverlayHelperWindow.m +++ b/trunk/Bricksmith/Source/Widgets/OverlayHelperWindow.m @@ -65,6 +65,8 @@ - (id) initWithContentRect:(NSRect)contentRect [self setAlphaValue:.999]; [self setIgnoresMouseEvents:YES]; [self setBackgroundColor: [NSColor clearColor]]; + // for visual debugging uncomment this: + // [self setBackgroundColor: [NSColor colorWithRed:0 green:1 blue:0 alpha:0.2]]; } return self; diff --git a/trunk/Bricksmith/Source/Widgets/ViewportArranger.m b/trunk/Bricksmith/Source/Widgets/ViewportArranger.m index f96cdf8..2a2c1a3 100644 --- a/trunk/Bricksmith/Source/Widgets/ViewportArranger.m +++ b/trunk/Bricksmith/Source/Widgets/ViewportArranger.m @@ -19,7 +19,7 @@ // provides a way to look up the enclosing view pane @interface ViewportArrangerPlacard: NSView -@property (nonatomic, unsafe_unretained) LDrawViewerContainer* container; +@property (nonatomic, weak) LDrawViewerContainer* container; @end @implementation ViewportArrangerPlacard @@ -153,7 +153,7 @@ - (void) splitViewportClicked:(id)sender NSSplitView *arrangementView = (NSSplitView*)[sourceColumn superview]; ExtendedSplitView *newColumn = nil; - LDrawViewerContainer *newViewport = [[self newViewport] autorelease]; + LDrawViewerContainer *newViewport = [self newViewport]; NSRect sourceViewFrame = NSZeroRect; NSRect newViewFrame = NSZeroRect; @@ -162,7 +162,7 @@ - (void) splitViewportClicked:(id)sender if(makeNewColumn == YES) { sourceViewFrame = [sourceColumn frame]; - newColumn = [[[ExtendedSplitView alloc] initWithFrame:NSMakeRect(0,0,12,12)] autorelease]; + newColumn = [[ExtendedSplitView alloc] initWithFrame:NSMakeRect(0,0,12,12)]; [newColumn setDelegate:self]; @@ -426,7 +426,7 @@ - (NSButton *) newSplitButton //============================================================================== - (ViewportArrangerPlacard *) newSplitPlacard { - NSButton *splitButton = [[self newSplitButton] autorelease]; + NSButton *splitButton = [self newSplitButton]; ViewportArrangerPlacard *placardContainer = [[ViewportArrangerPlacard alloc] initWithFrame:NSMakeRect(0, 0, 12, 12)]; [placardContainer addSubview:splitButton]; @@ -448,8 +448,8 @@ - (ViewportArrangerPlacard *) newSplitPlacard //============================================================================== - (ViewportArrangerPlacard *) newSplitClosePlacard { - NSButton* splitButton = [[self newSplitButton] autorelease]; - NSButton* closeButton = [[self newCloseButton] autorelease]; + NSButton* splitButton = [self newSplitButton]; + NSButton* closeButton = [self newCloseButton]; ViewportArrangerPlacard* placardContainer = [[ViewportArrangerPlacard alloc] initWithFrame:NSMakeRect(0, 0, 12, 24)]; [placardContainer addSubview:splitButton]; @@ -593,14 +593,14 @@ - (void) restoreViewportsWithAutosaveName:(NSString *)autosaveNameIn rows = [[viewCountPerColumn objectAtIndex:columnCounter] integerValue]; // The Column. - columnView = [[[ExtendedSplitView alloc] initWithFrame:NSMakeRect(0, 0, 256, 256)] autorelease]; + columnView = [[ExtendedSplitView alloc] initWithFrame:NSMakeRect(0, 0, 256, 256)]; [columnView setDelegate:self]; [self addSubview:columnView]; // The Rows for(rowCounter = 0; rowCounter < rows; rowCounter++) { - rowView = [[self newViewport] autorelease]; + rowView = [self newViewport]; [columnView addSubview:rowView]; if([self->delegate respondsToSelector:@selector(viewportArranger:didAddViewport:sourceViewport:)]) @@ -717,11 +717,11 @@ - (void) updatePlacardsForViewports // If there only one viewport in the column, disable the close box. if(columnCount == 1 && rowCount == 1) { - placard = [[self newSplitPlacard] autorelease]; + placard = [self newSplitPlacard]; } else { - placard = [[self newSplitClosePlacard] autorelease]; + placard = [self newSplitClosePlacard]; } placard.container = currentRow; @@ -731,20 +731,4 @@ - (void) updatePlacardsForViewports }//end updatePlacardsForViewports -#pragma mark - -#pragma mark DESTRUCTOR -#pragma mark - - -//========== dealloc =========================================================== -// -// Purpose: Making our final arrangements. -// -//============================================================================== -- (void) dealloc -{ - [super dealloc]; - -}//end dealloc - - @end