discuss-gnustep
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

NSTableView bug fixed


From: Andreas Höschler
Subject: NSTableView bug fixed
Date: Sun, 11 Oct 2020 19:54:21 +0200

Hi Fred,

I just hunted down a bug in NSTableView. A test app would be an application 
with a tableview with a couple of columns with formatters. Entering data stops 
working once a cell with a formatter was hit. This is due to

NSTableView.m   - (void) validateEditing

existing without setting _isValidating back to NO.

The following fix below (see line marked with  // <-------) does the trick. 
Could you please integrate this fix into the stream? :-)

Thanks a lot,

 Andreas

***

- (void) validateEditing
{
   if (_textObject && (_isValidating == NO))
     {
      NSFormatter *formatter;
      NSString *string;
      id newObjectValue = nil;
      BOOL validatedOK = YES;
      
      // Avoid potential recursive sequences...
      _isValidating = YES;
      
      formatter = [_editedCell formatter];
      string = AUTORELEASE([[_textObject text] copy]);
      
      if (formatter != nil)
        {
         NSString *error;
         
         if ([formatter getObjectValue: &newObjectValue forString: string 
errorDescription: &error] == YES)
           {
            [_editedCell setObjectValue: newObjectValue];
            
            if (_dataSource_editable)
              {
               NSTableColumn *tb;
               
               tb = [_tableColumns objectAtIndex: _editedColumn];
               
               [self _setObjectValue: newObjectValue
               forTableColumn: tb
               row: _editedRow];
              }
            _isValidating = NO; return; // <-------
           }
         else
           {
            SEL sel = 
@selector(control:didFailToFormatString:errorDescription:);
            
            if ([_delegate respondsToSelector: sel])
              {
               validatedOK = [_delegate control: self 
               didFailToFormatString: string 
               errorDescription: error];
              }
            // Allow an empty string to fall through
            else if (![string isEqualToString: @""])
              {
               validatedOK = NO;
              }
           }
        }
      
      if (validatedOK)
        {
         [_editedCell setStringValue: string];
         
         if (_dataSource_editable)
           {
            NSTableColumn *tb;
            
            tb = [_tableColumns objectAtIndex: _editedColumn];
            
            [self _setObjectValue: string forTableColumn: tb row: _editedRow];
           }
        }
      
      // Avoid potential recursive sequences...
      _isValidating = NO;
     }
}




reply via email to

[Prev in Thread] Current Thread [Next in Thread]