we are currently in the process of establishing a stable desktop environment for Solaris based on GNUstep (a mission critical business application and some utility apps). It seems that Window Maker is no option right now (focus problems discussed on the list). So we are stuck to JDS (not optimal but ok for now). In order to stabilize things we did the following changes to GNUstep so far. Please feel free to comment on these changes and/or integrate them in the official GNUstep tree (we have no write access to cvs). We will from time to time repost this list whenever essential changes have been addded (in the hope this is usefull to someone). If there is a better target channel for this please let me know.
Best regards,
Andreas
base
NSCalendarDate
Don't raise exceptions here, return nil instead, otherwise creating dates from invalid strings (NSDateFormatter tries this often) leads to crashes.
if (month < 1 || month > 12)
{
[self dealloc]; return nil;
// NSWarnMLog(@"invalid month given - %u", month);
}
c = lastDayOfGregorianMonth(month, year);
if (day < 1 || day > c)
{
[self dealloc]; return nil;
// NSWarnMLog(@"invalid day given - %u", day);
}
if (hour > 23)
{
[self dealloc]; return nil;
// NSWarnMLog(@"invalid hour given - %u", hour);
}
if (minute > 59)
{
[self dealloc]; return nil;
// NSWarnMLog(@"invalid minute given - %u", minute);
}
if (second > 59)
{
[self dealloc]; return nil;
// NSWarnMLog(@"invalid second given - %u", second);
}
// Calculate date as GMT
s = GSTime(day, month, year, hour, minute, second, 0);
// Assign time zone detail
if (aTimeZone == nil)
{
_time_zone = localTZ; // retain is a no-op for the local timezone.
}
else
{
_time_zone = RETAIN(aTimeZone);
}
if (_calendar_format == nil)
{
_calendar_format = cformat;
}
_seconds_since_ref = s;
/*
* Adjust date so it is correct for time zone.
*/
oldOffset = offset(_time_zone, self);
s -= oldOffset;
_seconds_since_ref = s;
/*
* See if we need to adjust for daylight savings time
*/
newOffset = offset(_time_zone, self);
if (oldOffset != newOffset)
{
s -= (newOffset - oldOffset);
_seconds_since_ref = s;
oldOffset = offset(_time_zone, self);
/*
* If the adjustment puts us in another offset, we must be in the
* non-existent period at the start of daylight savings time.
*/
if (oldOffset != newOffset)
{
NSWarnMLog(@"init non-existent time at start of daylight savings");
}
}
return self;
}
NSDateFormatter
- (BOOL)getObjectValue:(id *)anObject forString:(NSString *)string errorDescription:(NSString**)error
{
NSCalendarDate *d = [NSCalendarDate dateWithString:string calendarFormat:_dateFormat];
if (d == nil)
{
if (_allowsNaturalLanguage)
{
d = [NSCalendarDate dateWithNaturalLanguageString:string];
}
if (d == nil)
{
if (error) *error = @"Couldn't convert to date";
return NO;
}
}
if (anObject) *anObject = d;
return YES;
}
NSNumberFormatter
- (BOOL)getObjectValue:(id*)anObject forString:(NSString *)string errorDescription:(NSString**)error
{
NSNumber *result = nil;
if (string)
{
NSRange thousandSeparatorRange = [string rangeOfString:@","];
NSRange decimalSeparatorRange = [string rangeOfString:@"."];
if (thousandSeparatorRange.length > 0 && decimalSeparatorRange.length > 0)
{
if (thousandSeparatorRange.location > decimalSeparatorRange.location)
string = [string stringAfterRemovingAllOccurancesOfString:@"."];
else
string = [string stringAfterRemovingAllOccurancesOfString:@","];
}
string = [string stringAfterReplacingAllOccurancesOfString:@"," withString:@"."];
result = [NSNumber numberWithDouble:[string doubleValue]];
}
if (result)
{
if (anObject) *anObject = result;
if (error) *error = nil;
return YES;
}
else
{
if (anObject) *anObject = nil;
if (error) *error = nil;
return NO;
}
}
I don't remember whatI changed in this method, but that's how it works
- (void) textDidChange: (NSNotification *)aNotification
{
NSDictionary *d;
NSFormatter *formatter;
formatter = [_cell formatter];
if (formatter != nil)
{
/*
* FIXME: This part needs heavy interaction with the yet to finish
* text system.
*
*/
NSString *partialString;
NSString *newString = nil;
NSString *error = nil;
BOOL wasAccepted;
if (wasAccepted == NO)
{
SEL sel = @selector(control:didFailToValidatePartialString:errorDescription:);
if ([_delegate respondsToSelector:sel])
[_delegate control:self
didFailToValidatePartialString: partialString
errorDescription: error];
}
if (newString != nil)
{
NSLog (@"Unimplemented: should set string to %@", newString);
// FIXME ! This would reset editing !
//[_text_object setString: newString];
}
else
{
if (wasAccepted == NO)
{
// FIXME: Need to delete last typed character (?!)
NSLog (@"Unimplemented: should delete last typed character");
}
}
/* We warn about nil for compatibiliy with MacOS X, which refuses
nil. */
if (string == nil)
{
NSDebugMLLog (@"MacOSXCompatibility",
@"Attempt to use nil as string value");
}
- (void)synchronizeTitleAndSelectedItem
{
int index;
if (!_pbcFlags.usesItemFromMenu) return;
if ([_menu numberOfItems] == 0)
{
index = -1;
}
else if (_pbcFlags.pullsDown)
{
index = 0;
}
else
{
index = [[_menu menuRepresentation] highlightedItemIndex];
if (index < 0) index = [self indexOfSelectedItem];
// if (index < 0) index = 0; // <--------------- this is bad
}