@@ -5056,59 +5056,57 @@ - (BOOL)setStateFromConnectionFile:(NSString *)path
5056
5056
}
5057
5057
5058
5058
/**
5059
- * Restore session from SPF file if given
5059
+ * Restore the session from SPF file if given.
5060
5060
*/
5061
5061
- (void)restoreSession
5062
5062
{
5063
5063
@autoreleasepool {
5064
5064
// Check and set the table
5065
5065
NSArray *tables = [tablesListInstance tables];
5066
5066
5067
- BOOL isSelectedTableDefined = YES;
5068
-
5069
- if([tables indexOfObject:[spfSession objectForKey:@"table"]] == NSNotFound) {
5070
- isSelectedTableDefined = NO;
5071
- }
5067
+ NSUInteger tableIndex = [tables indexOfObject:[spfSession objectForKey:@"table"]];
5072
5068
5073
5069
// Restore toolbar setting
5074
- if([spfSession objectForKey:@"isToolbarVisible"]) {
5075
- [mainToolbar setVisible:[[spfSession objectForKey:@"isToolbarVisible"] boolValue]];
5070
+ if ([spfSession objectForKey:@"isToolbarVisible"]) {
5071
+ [[ mainToolbar onMainThread] setVisible:[[spfSession objectForKey:@"isToolbarVisible"] boolValue]];
5076
5072
}
5077
5073
5078
5074
// Reset database view encoding if differs from default
5079
- if([spfSession objectForKey:@"connectionEncoding"] && ![[mySQLConnection encoding] isEqualToString:[spfSession objectForKey:@"connectionEncoding"]]) {
5075
+ if ([spfSession objectForKey:@"connectionEncoding"] && ![[mySQLConnection encoding] isEqualToString:[spfSession objectForKey:@"connectionEncoding"]]) {
5080
5076
[self setConnectionEncoding:[spfSession objectForKey:@"connectionEncoding"] reloadingViews:YES];
5081
5077
}
5082
5078
5083
- if(isSelectedTableDefined ) {
5079
+ if (tableIndex != NSNotFound ) {
5084
5080
// Set table content details for restore
5085
- if([spfSession objectForKey:@"contentSortCol"]) [tableContentInstance setSortColumnNameToRestore:[spfSession objectForKey:@"contentSortCol"] isAscending:[[spfSession objectForKey:@"contentSortColIsAsc"] boolValue]];
5086
- if([spfSession objectForKey:@"contentPageNumber"]) [tableContentInstance setPageToRestore:[[spfSession objectForKey:@"pageNumber"] integerValue]];
5087
- if([spfSession objectForKey:@"contentViewport"]) [tableContentInstance setViewportToRestore:NSRectFromString([spfSession objectForKey:@"contentViewport"])];
5088
- if([spfSession objectForKey:@"contentFilterV2"]) [tableContentInstance setFiltersToRestore:[spfSession objectForKey:@"contentFilterV2"]];
5081
+ if ([spfSession objectForKey:@"contentSortCol"]) [tableContentInstance setSortColumnNameToRestore:[spfSession objectForKey:@"contentSortCol"] isAscending:[[spfSession objectForKey:@"contentSortColIsAsc"] boolValue]];
5082
+ if ([spfSession objectForKey:@"contentPageNumber"]) [tableContentInstance setPageToRestore:[[spfSession objectForKey:@"pageNumber"] integerValue]];
5083
+ if ([spfSession objectForKey:@"contentViewport"]) [tableContentInstance setViewportToRestore:NSRectFromString([spfSession objectForKey:@"contentViewport"])];
5084
+ if ([spfSession objectForKey:@"contentFilterV2"]) [tableContentInstance setFiltersToRestore:[spfSession objectForKey:@"contentFilterV2"]];
5089
5085
5090
5086
// Select table
5091
- [tablesListInstance selectTableAtIndex:[NSNumber numberWithInteger:[tables indexOfObject:[spfSession objectForKey:@"table"]]] ];
5087
+ [[ tablesListInstance onMainThread] selectTableAtIndex:@(tableIndex) ];
5092
5088
5093
5089
// Restore table selection indexes
5094
- if([spfSession objectForKey:@"contentSelection"]) {
5090
+ if ([spfSession objectForKey:@"contentSelection"]) {
5095
5091
[tableContentInstance setSelectionToRestore:[spfSession objectForKey:@"contentSelection"]];
5096
5092
}
5097
5093
5098
- [[tablesListInstance valueForKeyPath:@"tablesListView"] scrollRowToVisible:[tables indexOfObject:[spfSession objectForKey:@"selectedTable"]]];
5099
-
5094
+ // Scroll to table
5095
+ #warning Private ivar accessed from outside (#2978)
5096
+ [[[tablesListInstance valueForKeyPath:@"tablesListView"] onMainThread] scrollRowToVisible:tableIndex];
5100
5097
}
5101
5098
5102
5099
// update UI on main thread
5103
5100
SPMainQSync(^{
5104
5101
// Select view
5105
5102
NSString *view = [spfSession objectForKey:@"view"];
5106
- if([view isEqualToString:@"SP_VIEW_STRUCTURE"]) [self viewStructure:self];
5107
- else if([view isEqualToString:@"SP_VIEW_CONTENT"]) [self viewContent:self];
5108
- else if([view isEqualToString:@"SP_VIEW_CUSTOMQUERY"]) [self viewQuery:self];
5109
- else if([view isEqualToString:@"SP_VIEW_STATUS"]) [self viewStatus:self];
5110
- else if([view isEqualToString:@"SP_VIEW_RELATIONS"]) [self viewRelations:self];
5111
- else if([view isEqualToString:@"SP_VIEW_TRIGGERS"]) [self viewTriggers:self];
5103
+
5104
+ if ([view isEqualToString:@"SP_VIEW_STRUCTURE"]) [self viewStructure:self];
5105
+ else if ([view isEqualToString:@"SP_VIEW_CONTENT"]) [self viewContent:self];
5106
+ else if ([view isEqualToString:@"SP_VIEW_CUSTOMQUERY"]) [self viewQuery:self];
5107
+ else if ([view isEqualToString:@"SP_VIEW_STATUS"]) [self viewStatus:self];
5108
+ else if ([view isEqualToString:@"SP_VIEW_RELATIONS"]) [self viewRelations:self];
5109
+ else if ([view isEqualToString:@"SP_VIEW_TRIGGERS"]) [self viewTriggers:self];
5112
5110
5113
5111
[self updateWindowTitle:self];
5114
5112
});
0 commit comments