mirror of
https://github.com/gnustep/libs-gui.git
synced 2025-04-23 07:00:46 +00:00
memory panel improvements.
git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/gui/trunk@22729 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
parent
59e051eaef
commit
aa684478fd
3 changed files with 22 additions and 72 deletions
|
@ -2,6 +2,8 @@
|
|||
|
||||
* Source/GSMemoryPanel.m: Extend to allow snapshots of the memory
|
||||
to be taken so we can compare memory at different points in time.
|
||||
Simplify code and fix bug where re-ordering sort in table would
|
||||
also change table contents.
|
||||
|
||||
2006-03-26 Maurizio Boriani <baux@gnu.org>
|
||||
|
||||
|
|
|
@ -39,13 +39,10 @@
|
|||
@interface GSMemoryPanel: NSPanel
|
||||
{
|
||||
NSTableView *table;
|
||||
NSMutableArray *classArray;
|
||||
NSMutableArray *countArray;
|
||||
NSMutableArray *totalArray;
|
||||
NSMutableArray *peakArray;
|
||||
NSMutableArray *array;
|
||||
/* Are we ordering by class name, or by count or total or peak number
|
||||
of instances ? */
|
||||
int orderingBy;
|
||||
SEL orderingBy;
|
||||
}
|
||||
+ (id) sharedMemoryPanel;
|
||||
|
||||
|
|
|
@ -184,6 +184,8 @@ static GSMemoryPanel *sharedGSMemoryPanel = nil;
|
|||
/* Activate debugging of allocation. */
|
||||
GSDebugAllocationActive (YES);
|
||||
|
||||
orderingBy = @selector(compareByCount:);
|
||||
array = [NSMutableArray new];
|
||||
hbox = [GSHbox new];
|
||||
[hbox setDefaultMinXMargin: 5];
|
||||
[hbox setBorder: 5];
|
||||
|
@ -219,9 +221,6 @@ static GSMemoryPanel *sharedGSMemoryPanel = nil;
|
|||
[hbox addView: button];
|
||||
RELEASE (button);
|
||||
|
||||
/* Ordering by number of objects by default */
|
||||
orderingBy = OrderByCount;
|
||||
|
||||
classColumn = [[NSTableColumn alloc] initWithIdentifier: @"Class"];
|
||||
[classColumn setEditable: NO];
|
||||
[[classColumn headerCell] setStringValue: @"Class Name"];
|
||||
|
@ -296,40 +295,37 @@ static GSMemoryPanel *sharedGSMemoryPanel = nil;
|
|||
|
||||
- (void) dealloc
|
||||
{
|
||||
RELEASE(classArray);
|
||||
RELEASE(countArray);
|
||||
RELEASE(totalArray);
|
||||
RELEASE(peakArray);
|
||||
|
||||
RELEASE(array);
|
||||
[super dealloc];
|
||||
}
|
||||
|
||||
- (int) numberOfRowsInTableView: (NSTableView *)aTableView
|
||||
{
|
||||
return [countArray count];
|
||||
return [array count];
|
||||
}
|
||||
|
||||
- (id) tableView: (NSTableView *)aTableView
|
||||
objectValueForTableColumn: (NSTableColumn *)aTableColumn
|
||||
row:(int)rowIndex
|
||||
{
|
||||
GSMemoryPanelEntry *entry = [array objectAtIndex: rowIndex];
|
||||
id identifier = [aTableColumn identifier];
|
||||
|
||||
if ([identifier isEqual: @"Class"])
|
||||
{
|
||||
return [classArray objectAtIndex: rowIndex];
|
||||
return [entry string];
|
||||
}
|
||||
else if ([identifier isEqual: @"Count"])
|
||||
{
|
||||
return [countArray objectAtIndex: rowIndex];
|
||||
return [entry count];
|
||||
}
|
||||
else if ([identifier isEqual: @"Total"])
|
||||
{
|
||||
return [totalArray objectAtIndex: rowIndex];
|
||||
return [entry total];
|
||||
}
|
||||
else if ([identifier isEqual: @"Peak"])
|
||||
{
|
||||
return [peakArray objectAtIndex: rowIndex];
|
||||
return [entry peak];
|
||||
}
|
||||
|
||||
NSLog (@"Hi, I am a bug in your table view");
|
||||
|
@ -354,20 +350,13 @@ static GSMemoryPanel *sharedGSMemoryPanel = nil;
|
|||
{
|
||||
Class *classList = GSDebugAllocationClassList ();
|
||||
Class *pointer;
|
||||
NSMutableArray *array = [NSMutableArray new];
|
||||
NSArray *array_imm;
|
||||
SEL orderSel = NULL;
|
||||
GSMemoryPanelEntry *entry;
|
||||
int i, count, total, peak;
|
||||
NSString *className;
|
||||
NSMutableArray *classes = [NSMutableArray new];
|
||||
NSMutableArray *counts = [NSMutableArray new];
|
||||
NSMutableArray *totals = [NSMutableArray new];
|
||||
NSMutableArray *peaks = [NSMutableArray new];
|
||||
|
||||
pointer = classList;
|
||||
i = 0;
|
||||
|
||||
[array removeAllObjects];
|
||||
while (pointer[i] != NULL)
|
||||
{
|
||||
className = NSStringFromClass (pointer[i]);
|
||||
|
@ -385,46 +374,7 @@ static GSMemoryPanel *sharedGSMemoryPanel = nil;
|
|||
}
|
||||
NSZoneFree(NSDefaultMallocZone(), classList);
|
||||
|
||||
switch (orderingBy)
|
||||
{
|
||||
case (OrderByClassName):
|
||||
orderSel = @selector(compareByClassName:);
|
||||
break;
|
||||
case (OrderByCount):
|
||||
orderSel = @selector(compareByCount:);
|
||||
break;
|
||||
case (OrderByTotal):
|
||||
orderSel = @selector(compareByTotal:);
|
||||
break;
|
||||
case (OrderByPeak):
|
||||
orderSel = @selector(compareByPeak:);
|
||||
break;
|
||||
}
|
||||
|
||||
array_imm = [array sortedArrayUsingSelector: orderSel];
|
||||
RELEASE (array);
|
||||
|
||||
count = [array_imm count];
|
||||
for (i = 0; i < count; i++)
|
||||
{
|
||||
entry = [array_imm objectAtIndex: i];
|
||||
[counts addObject: [entry count]];
|
||||
[totals addObject: [entry total]];
|
||||
[peaks addObject: [entry peak]];
|
||||
[classes addObject: [entry string]];
|
||||
}
|
||||
|
||||
ASSIGN (classArray, classes);
|
||||
RELEASE (classes);
|
||||
|
||||
ASSIGN (countArray, counts);
|
||||
RELEASE (counts);
|
||||
|
||||
ASSIGN (totalArray, totals);
|
||||
RELEASE (totals);
|
||||
|
||||
ASSIGN (peakArray, peaks);
|
||||
RELEASE (peaks);
|
||||
[array sortUsingSelector: orderingBy];
|
||||
|
||||
[table reloadData];
|
||||
}
|
||||
|
@ -434,7 +384,7 @@ static GSMemoryPanel *sharedGSMemoryPanel = nil;
|
|||
int selectedColumn = [table clickedColumn];
|
||||
NSArray *tableColumns = [table tableColumns];
|
||||
id identifier;
|
||||
int newOrderingBy = 0;
|
||||
SEL newOrderingBy = @selector(compareByCount:);
|
||||
|
||||
if (selectedColumn == -1)
|
||||
{
|
||||
|
@ -446,19 +396,19 @@ static GSMemoryPanel *sharedGSMemoryPanel = nil;
|
|||
|
||||
if ([identifier isEqual: @"Class"])
|
||||
{
|
||||
newOrderingBy = OrderByClassName;
|
||||
newOrderingBy = @selector(compareByClassName:);
|
||||
}
|
||||
else if ([identifier isEqual: @"Count"])
|
||||
{
|
||||
newOrderingBy = OrderByCount;
|
||||
newOrderingBy = @selector(compareByCount:);
|
||||
}
|
||||
else if ([identifier isEqual: @"Total"])
|
||||
{
|
||||
newOrderingBy = OrderByTotal;
|
||||
newOrderingBy = @selector(compareByTotal:);
|
||||
}
|
||||
else if ([identifier isEqual: @"Peak"])
|
||||
{
|
||||
newOrderingBy = OrderByPeak;
|
||||
newOrderingBy = @selector(compareByPeak:);
|
||||
}
|
||||
|
||||
if (newOrderingBy == orderingBy)
|
||||
|
@ -468,7 +418,8 @@ static GSMemoryPanel *sharedGSMemoryPanel = nil;
|
|||
else
|
||||
{
|
||||
orderingBy = newOrderingBy;
|
||||
[self update: self];
|
||||
[array sortUsingSelector: orderingBy];
|
||||
[table reloadData];
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue