Skip to content
Snippets Groups Projects
Commit d6d7d25a authored by George Nachman's avatar George Nachman
Browse files

Add logging to try to find cause of tabs out of order issue.

parent 7a3f5a1d
No related branches found
No related tags found
No related merge requests found
Loading
Loading
@@ -245,6 +245,19 @@ static NSRect PSMConvertAccessibilityFrameToScreen(NSView *view, NSRect frame) {
[super dealloc];
}
 
- (NSString *)description {
id identifier = nil;
if ([self.representedObject respondsToSelector:@selector(identifier)]) {
identifier = [self.representedObject identifier];
}
return [NSString stringWithFormat:@"<%@: %p representedObject=%@ identifier=%@ objectCount=%@>",
NSStringFromClass([self class]),
self,
self.representedObject,
identifier,
@(self.count)];
}
// we don't want this to be the first responder in the chain
- (BOOL)acceptsFirstResponder {
return NO;
Loading
Loading
Loading
Loading
@@ -216,6 +216,31 @@ const NSInteger kPSMStartResizeAnimation = 0;
}
}
 
- (void)sanityCheckFailedWithCallsite:(NSString *)callsite reason:(NSString *)reason {
ILog(@"Sanity check failed from %@ for reason %@. Cells=%@. tabView.tabViewItems=%@ stack:\n%@",
callsite,
reason,
self.cells,
self.tabView.tabViewItems,
[NSThread callStackSymbols]);
}
- (void)sanityCheck:(NSString *)callsite {
if ([[PSMTabDragAssistant sharedDragAssistant] isDragging]) {
return;
}
if (self.tabView.tabViewItems.count != self.cells.count) {
[self sanityCheckFailedWithCallsite:callsite reason:@"count mismatch"];
} else {
for (NSInteger i = 0; i < self.cells.count; i++) {
NSTabViewItem *tabViewItem = self.tabView.tabViewItems[i];
PSMTabBarCell *cell = self.cells[i];
if (cell.representedObject != tabViewItem) {
[self sanityCheckFailedWithCallsite:callsite reason:@"cells[i].representedObject != tabView.tabViewItems[i].representedObject"];
}
}
}
}
 
#pragma mark -
#pragma mark Accessors
Loading
Loading
Loading
Loading
@@ -437,6 +437,8 @@
didDropTabViewItem:[[self draggedCell] representedObject]
inTabBar:[self destinationTabBar]];
}
[[self destinationTabBar] sanityCheck:@"destination performDragOperation"];
[[self sourceTabBar] sanityCheck:@"source performDragOperation"];
}
 
[[NSNotificationCenter defaultCenter] postNotificationName:PSMTabDragDidEndNotification object:nil];
Loading
Loading
@@ -490,16 +492,19 @@
didDropTabViewItem:[[self draggedCell] representedObject]
inTabBar:control];
}
[control sanityCheck:@"add dragged tab to new window"];
} else {
NSLog(@"Delegate returned no control to add to.");
[[[self sourceTabBar] cells] insertObject:[self draggedCell] atIndex:[self draggedCellIndex]];
[[[self sourceTabBar] window] setAlphaValue:1]; // Make the window visible again.
[[[self sourceTabBar] window] orderFront:nil];
[[self sourceTabBar] sanityCheck:@"delegate returned no control to add to"];
}
 
} else {
// put cell back
[[[self sourceTabBar] cells] insertObject:[self draggedCell] atIndex:[self draggedCellIndex]];
[[self sourceTabBar] sanityCheck:@"put cell back"];
}
 
[[NSNotificationCenter defaultCenter] postNotificationName:PSMTabDragDidEndNotification object:nil];
Loading
Loading
@@ -542,6 +547,8 @@
[_sineCurveWidths removeAllObjects];
[self setTargetCell:nil];
self.temporarilyHiddenWindow = nil;
[[self sourceTabBar] sanityCheck:@"finishDrag source"];
[[self destinationTabBar] sanityCheck:@"finishDrag destination"];
}
 
- (void)draggingBeganAt:(NSPoint)aPoint {
Loading
Loading
@@ -620,7 +627,7 @@
 
- (void)calculateDragAnimationForTabBar:(PSMTabBarControl *)control {
BOOL removeFlag = YES;
NSMutableArray *cells = [control cells];
NSArray *cells = [control cells];
int i, cellCount = [cells count];
float position = [control orientation] == PSMTabBarHorizontalOrientation ? [[control style] leftMarginForTabBarControl] : [[control style] topMarginForTabBarControl];
 
Loading
Loading
@@ -721,6 +728,7 @@
[[control cells] replaceObjectAtIndex:cellIndex withObject:pc];
[[control cells] removeObjectAtIndex:(cellIndex + 1)];
[[control cells] removeObjectAtIndex:(cellIndex - 1)];
ILog(@"distributePlaceholdersInTabBar:withDraggedCell:%@", cell);
return;
}
 
Loading
Loading
@@ -750,6 +758,7 @@
} else {
[[control cells] addObject:pc];
}
ILog(@"distributePlaceholdersInTabBar draggedCell=%@", draggedCell);
}
 
- (void)removeAllPlaceholdersFromTabBar:(PSMTabBarControl *)control {
Loading
Loading
Loading
Loading
@@ -59,5 +59,6 @@ Protocol to be observed by all style delegate objects. These objects handle the
@interface PSMTabBarControl (StyleAccessors)
 
- (NSMutableArray *)cells;
- (void)sanityCheck:(NSString *)callsite;
 
@end
Loading
Loading
@@ -383,6 +383,14 @@ static void SetAgainstGrainDim(BOOL isVertical, NSSize *dest, CGFloat value) {
[super dealloc];
}
 
- (NSString *)description {
return [NSString stringWithFormat:@"<%@: %p label=%@ objectCount=%@>",
NSStringFromClass([self class]),
self,
tabViewItem_.label,
@(objectCount_)];
}
#pragma mark - NSCopying
 
- (id)copyWithZone:(NSZone *)zone {
Loading
Loading
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment