Permalink
Browse files

It was possible to enable the filter rule editor when no table was se…

…lected, which caused an exception when changing views #3255
  • Loading branch information...
dmoagx committed Oct 27, 2018
1 parent 145ee33 commit ea1325bf25e2bbb30efa9d5077e82b4d0f66135e
Showing with 20 additions and 3 deletions.
  1. +3 −0 Source/SPCompatibility.h
  2. +1 −1 Source/SPDatabaseDocument.m
  3. +10 −2 Source/SPRuleFilterController.m
  4. +6 −0 Source/SPTableContent.m
@@ -176,6 +176,9 @@ typedef struct {
#if __MAC_OS_X_VERSION_MAX_ALLOWED < __MAC_10_13
// was an anonymous enum before
#define NSFontPanelModeMask NSUInteger
#endif
#pragma mark - 10.14 Mojave
@@ -3598,7 +3598,7 @@ - (IBAction) makeTableListFilterHaveFocus:(id)sender
/**
* Menu item validation.
*/
*/
- (BOOL)validateMenuItem:(NSMenuItem *)menuItem
{
SEL action = [menuItem action];
@@ -921,6 +921,9 @@ - (BOOL)isEmpty
- (void)addFilterExpression
{
// reject this if no table columns exist: would cause invalid state (empty filter rows)
if(![columns count]) return;
[filterRuleEditor insertRowAtIndex:0 withType:NSRuleEditorRowTypeSimple asSubrowOfRow:-1 animate:NO];
}
@@ -979,7 +982,8 @@ - (NSDictionary *)_serializedFilterIncludingFilterDefinition:(BOOL)includeDefini
{
NSMutableArray *rootItems = [NSMutableArray arrayWithCapacity:[[_modelContainer model] count]];
for(NSDictionary *item in [_modelContainer model]) {
[rootItems addObject:[self _serializeSubtree:item includingDefinition:includeDefinition]];
NSDictionary *sub = [self _serializeSubtree:item includingDefinition:includeDefinition];
if(sub) [rootItems addObject:sub];
}
//the root serialized filter can either be an AND of multiple root items or a single root item
if([rootItems count] == 1) {
@@ -1003,7 +1007,8 @@ - (NSDictionary *)_serializeSubtree:(NSDictionary *)item includingDefinition:(BO
NSArray *subrows = [item objectForKey:@"subrows"];
NSMutableArray *children = [[NSMutableArray alloc] initWithCapacity:[subrows count]];
for(NSDictionary *subitem in subrows) {
[children addObject:[self _serializeSubtree:subitem includingDefinition:includeDefinition]];
NSDictionary *sub = [self _serializeSubtree:subitem includingDefinition:includeDefinition];
if(sub) [children addObject:sub];
}
StringNode *node = [[item objectForKey:@"criteria"] objectAtIndex:0];
BOOL isConjunction = [@"AND" isEqualToString:[node value]];
@@ -1018,6 +1023,9 @@ - (NSDictionary *)_serializeSubtree:(NSDictionary *)item includingDefinition:(BO
else {
NSArray *criteria = [item objectForKey:@"criteria"];
NSArray *displayValues = [item objectForKey:@"displayValues"];
if([criteria count] < 2 || [criteria count] != [displayValues count]) {
return nil;
}
ColumnNode *col = [criteria objectAtIndex:0];
OpNode *op = [criteria objectAtIndex:1];
NSMutableArray *filterValues = [[NSMutableArray alloc] initWithCapacity:2];
@@ -3931,6 +3931,12 @@ - (id)_contentValueForTableColumn:(NSUInteger)columnIndex row:(NSUInteger)rowInd
*/
- (void)makeContentFilterHaveFocus
{
// don't show the filter UI if no table is selected - would result in invalid state
if (!selectedTable || [selectedTable isEqualToString:@""]) {
NSBeep();
return;
}
[self setRuleEditorVisible:YES animate:YES];
[toggleRuleFilterButton setState:NSOnState];
[ruleFilterController focusFirstInputField];

0 comments on commit ea1325b

Please sign in to comment.