From 40b51164e2eb993d8e691b00e1a85e73f42c7a48 Mon Sep 17 00:00:00 2001 From: Robert Sesek Date: Sat, 4 Aug 2007 15:29:39 -0700 Subject: [PATCH] Fixing the updateSourceViewer function to not depend on -[NSArrayController selection] which is unreliable in returning the right proxy object * Source/DebuggerWindowController.h: Remove _currentFile as it's not really needed * Source/DebuggerWindowController.m: ([DebuggerWindowController updateSourceViewer]): Remove the dependency on [NSArrayController selection] and don't bother checking with _currentFile anymore --- Source/DebuggerWindowController.h | 1 - Source/DebuggerWindowController.m | 19 +++++++------------ 2 files changed, 7 insertions(+), 13 deletions(-) diff --git a/Source/DebuggerWindowController.h b/Source/DebuggerWindowController.h index 3d5c333..9e58b4a 100644 --- a/Source/DebuggerWindowController.h +++ b/Source/DebuggerWindowController.h @@ -30,7 +30,6 @@ IBOutlet NSTextView *_sourceViewer; IBOutlet NSScrollView *_sourceViewerScroller; - NSString *_currentFile; } - (id)initWithConnection: (DebuggerConnection *)cnx; diff --git a/Source/DebuggerWindowController.m b/Source/DebuggerWindowController.m index 3e1ece5..b470a44 100644 --- a/Source/DebuggerWindowController.m +++ b/Source/DebuggerWindowController.m @@ -140,27 +140,22 @@ * Does the actual updating of the source viewer by reading in the file */ - (void)updateSourceViewer -{ - NSString *filename = [[_stackController selection] valueForKey: @"filename"]; - if (filename == NSNoSelectionMarker) +{ + int selection = [_stackController selectionIndex]; + if (selection == NSNotFound) { - _currentFile = nil; [_sourceViewer setString: @""]; return; } + // get the filename and then set the text + NSString *filename = [[_stack objectAtIndex: selection] valueForKey: @"filename"]; filename = [[NSURL URLWithString: filename] path]; - if (filename == _currentFile) - { - return; - } - - _currentFile = filename; - NSString *text = [NSString stringWithContentsOfFile: _currentFile]; + NSString *text = [NSString stringWithContentsOfFile: filename]; [_sourceViewer setString: text]; // go through the document until we find the NSRange for the line we want - int destination = [[[_stackController selection] valueForKey: @"lineno"] intValue]; + int destination = [[[_stack objectAtIndex: selection] valueForKey: @"lineno"] intValue]; int rangeIndex = 0; for (int line = 0; line < destination; line++) { -- 2.22.5