From 9207316488f4fb8908c9732baabc0d78488ec170 Mon Sep 17 00:00:00 2001 From: Mitchell Livingston Date: Mon, 9 Jun 2008 23:23:55 +0000 Subject: [PATCH] make the pieces view a bit more efficient in terms of not storing values when it's not shown --- macosx/InfoWindowController.m | 11 ++++++++--- macosx/PiecesView.h | 2 +- macosx/PiecesView.m | 23 +++++++++-------------- 3 files changed, 18 insertions(+), 18 deletions(-) diff --git a/macosx/InfoWindowController.m b/macosx/InfoWindowController.m index cdb459947..a1232f38d 100644 --- a/macosx/InfoWindowController.m +++ b/macosx/InfoWindowController.m @@ -690,9 +690,14 @@ typedef enum switch (oldTabTag) { + case TAB_ACTIVITY_TAG: + [fPiecesView clearView]; + break; + case TAB_TRACKER_TAG: oldResizeSaveKey = @"InspectorContentHeightTracker"; break; + case TAB_PEERS_TAG: //if in the middle of animating, just stop and resize immediately if (fWebSeedTableAnimation) @@ -705,6 +710,7 @@ typedef enum oldResizeSaveKey = @"InspectorContentHeightPeers"; break; + case TAB_FILES_TAG: [[QuickLookController quickLook] updateQuickLook]; @@ -736,8 +742,6 @@ typedef enum case TAB_ACTIVITY_TAG: identifier = TAB_ACTIVITY_IDENT; title = NSLocalizedString(@"Activity", "Inspector -> title"); - - [fPiecesView resetView]; break; case TAB_TRACKER_TAG: identifier = TAB_TRACKER_IDENT; @@ -1142,7 +1146,8 @@ typedef enum [fPiecesControl setSelected: !available forSegment: PIECES_CONTROL_PROGRESS]; [[NSUserDefaults standardUserDefaults] setBool: available forKey: @"PiecesViewShowAvailability"]; - [fPiecesView resetView]; + [fPiecesView clearView]; + [fPiecesView updateView]; } - (void) revealTorrentFile: (id) sender diff --git a/macosx/PiecesView.h b/macosx/PiecesView.h index 35ed48921..9de87efa1 100644 --- a/macosx/PiecesView.h +++ b/macosx/PiecesView.h @@ -40,7 +40,7 @@ - (void) setTorrent: (Torrent *) torrent; -- (void) resetView; +- (void) clearView; - (void) updateView; @end diff --git a/macosx/PiecesView.m b/macosx/PiecesView.m index 7490e6d56..dce5ad264 100644 --- a/macosx/PiecesView.m +++ b/macosx/PiecesView.m @@ -80,13 +80,7 @@ - (void) setTorrent: (Torrent *) torrent { - //reset the view to blank - NSImage * newBack = [fBack copy]; - [self setImage: newBack]; - [newBack release]; - - tr_free(fPieces); - fPieces = NULL; + [self clearView]; fTorrent = torrent; if (fTorrent) @@ -98,19 +92,20 @@ float width = [self bounds].size.width; fWidth = (width - (fAcross + 1) * BETWEEN) / fAcross; fExtraBorder = (width - ((fWidth + BETWEEN) * fAcross + BETWEEN)) / 2; - - [self updateView]; } - else - [self setNeedsDisplay]; + + //reset the view to blank + NSImage * newBack = [fBack copy]; + [self setImage: newBack]; + [newBack release]; + + [self setNeedsDisplay]; } -- (void) resetView +- (void) clearView { tr_free(fPieces); fPieces = NULL; - - [self updateView]; } - (void) updateView