Skip to content

Commit 5d14864

Browse files
committed
Workspace: FileViewer: -windowWillClose: unset window delegate before releasing window to avoid app crash.
1 parent e959110 commit 5d14864

File tree

1 file changed

+18
-14
lines changed

1 file changed

+18
-14
lines changed

Applications/Workspace/Viewers/FileViewer.m

+18-14
Original file line numberDiff line numberDiff line change
@@ -137,15 +137,15 @@ - (void)useViewer:(id<Viewer>)aViewer
137137
// to decrease retain count on FileViwer.
138138
// Example: [self windowWillClose:]
139139
[[viewer view] removeFromSuperview];
140-
[viewer autorelease];
140+
[viewer release];
141141
}
142142
}
143143
@end
144144

145145
@implementation FileViewer
146146

147147
//=============================================================================
148-
// Create and destroy
148+
#pragma mark - Create and destroy
149149
//=============================================================================
150150

151151
- initRootedAtPath:(NSString *)aRootPath viewer:(NSString *)viewerType isRoot:(BOOL)isRoot
@@ -462,7 +462,7 @@ - (void)dealloc
462462
}
463463

464464
//=============================================================================
465-
// Accessories
465+
#pragma mark - Accessories
466466
//=============================================================================
467467

468468
- (BOOL)isRootViewer
@@ -499,7 +499,7 @@ - (PathView *)pathView
499499
}
500500

501501
//=============================================================================
502-
// Path manipulations
502+
#pragma mark - Path manipulations
503503
//=============================================================================
504504
// displayedPath - relative path which displayed in PathView and Viewer
505505
// relativePath == displayedPath == path
@@ -540,7 +540,7 @@ - (void)setPathFromAbsolutePath:(NSString *)absolutePath
540540
if ([pathType isEqualToString:NSDirectoryFileType] ||
541541
[pathType isEqualToString:NSFilesystemFileType]) {
542542
ASSIGN(displayedPath, [self pathFromAbsolutePath:absolutePath]);
543-
ASSIGN(selection, nil);
543+
ASSIGN(selection, (id)nil);
544544
} else {
545545
// Set file selection ivar
546546
filename = [absolutePath lastPathComponent];
@@ -629,7 +629,7 @@ - (NSArray *)directoryContentsAtPath:(NSString *)relPath forPath:(NSString *)tar
629629
}
630630

631631
//=============================================================================
632-
// Actions
632+
#pragma mark - Actions
633633
//=============================================================================
634634

635635
- (NSArray *)checkSelection:(NSArray *)filenames atPath:(NSString *)relativePath
@@ -992,7 +992,7 @@ - (void)slideToPathFromShelfIcon:(PathIcon *)shelfIcon
992992
}
993993

994994
//=============================================================================
995-
// Shelf
995+
#pragma mark - Shelf
996996
//=============================================================================
997997

998998
- (void)restoreShelf
@@ -1032,7 +1032,7 @@ - (void)restoreShelf
10321032
}
10331033

10341034
//=============================================================================
1035-
// Viewer delegate (BrowserViewer, IconViewer, ListViewer, etc.)
1035+
#pragma mark - Viewer delegate (BrowserViewer, IconViewer, ListViewer, etc.)
10361036
//=============================================================================
10371037

10381038
// Called when viewer contains NXTIcons with editable label (IconViewer)
@@ -1047,7 +1047,7 @@ - (void)viewerDidSetPathTo:(NSString *)path selection:(NSArray *)files
10471047
}
10481048

10491049
//=============================================================================
1050-
// Splitview delegate
1050+
#pragma mark - Splitview delegate
10511051
//=============================================================================
10521052
- (void)splitView:(NSSplitView *)sender resizeSubviewsWithOldSize:(NSSize)oldSize
10531053
{
@@ -1112,7 +1112,7 @@ - (void)splitViewDidResizeSubviews:(NSNotification *)notification
11121112
}
11131113

11141114
//=============================================================================
1115-
// NXTIconLabel delegate
1115+
#pragma mark - NXTIconLabel delegate
11161116
//=============================================================================
11171117

11181118
// Called by icon in PathView or IconViewer
@@ -1143,7 +1143,7 @@ - (void)iconLabel:(NXTIconLabel *)anIconLabel
11431143
}
11441144

11451145
//=============================================================================
1146-
// Window
1146+
#pragma mark - Window
11471147
//=============================================================================
11481148
- (void)_updateFocusInWindow
11491149
{
@@ -1206,6 +1206,8 @@ - (void)windowWillClose:(NSNotification *)notif
12061206

12071207
// unset viewer to decrease retain count on FileViewer
12081208
[self useViewer:nil];
1209+
// AppKit will try to send notifications DidBecomeKey, DidBecomeMain to deallocated window (BUG?)
1210+
[window setDelegate:nil];
12091211

12101212
[[NSApp delegate] closeViewer:self];
12111213
}
@@ -1252,7 +1254,7 @@ - (void)handleWindowKeyUp:(NSEvent *)theEvent
12521254
}
12531255

12541256
//=============================================================================
1255-
// Notifications
1257+
#pragma mark - Notifications
12561258
//=============================================================================
12571259
- (void)shelfResizableStateChanged:(NSNotification *)notif
12581260
{
@@ -1537,7 +1539,7 @@ - (void)fileOperationProcessingFile:(NSNotification *)notif
15371539
}
15381540

15391541
//=============================================================================
1540-
// Dragging
1542+
#pragma mark - Dragging
15411543
// FileViewer is delegate for PathView (with PathIcon),
15421544
// ShelfView (with PathIcon).
15431545
//
@@ -1556,6 +1558,7 @@ - (NSDragOperation)draggingSourceOperationMaskForPaths:(NSArray *)paths
15561558
NSString *parentPath;
15571559
NSDragOperation mask;
15581560

1561+
NSLog(@"draggingSourceOperationMaskForPaths: %@", paths);
15591562
if ([paths count] == 0) {
15601563
return NSDragOperationNone;
15611564
}
@@ -1582,11 +1585,12 @@ - (NSDragOperation)draggingSourceOperationMaskForPaths:(NSArray *)paths
15821585
}
15831586
}
15841587

1588+
NSLog(@"draggingSourceOperationMaskForPaths: %@ - %lu", paths, mask);
15851589
return mask;
15861590
}
15871591

15881592
//=============================================================================
1589-
// Workspace menu
1593+
#pragma mark - Workspace menu
15901594
//=============================================================================
15911595

15921596
//--- Menu actions

0 commit comments

Comments
 (0)