bug-gnustep
[Top][All Lists]
Advanced

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

Problem with NSColor/NSString initialisation


From: Fred Kiefer
Subject: Problem with NSColor/NSString initialisation
Date: Tue, 10 Apr 2001 00:45:54 +0200

While searching for another problem in NSComboBoxCell I ran into an
initialization problem that I don't quite understand. Perhaps someone on
this list can explain it and even fix it?

When running this small test program, I get a lot of error messages from
NSColor.

#include <Foundation/NSAutoreleasePool.h>
#include <Foundation/NSString.h>
#include <AppKit/NSComboBox.h>
#include <AppKit/NSComboBoxCell.h>

int main (int argc, const char *argv[])
{
  CREATE_AUTORELEASE_POOL(pool);
  NSComboBox *cb;
  int n = 0;
/*
  NSString *str = @"0.000000 0.000000 0.000000";
  const char    *ptr = [str cString];
  float         r, g, b;

  //NSLog(@"Found string %s", ptr);
  n = sscanf(ptr, "%f %f %f", &r, &g, &b);
  if (n == 3)
  {
      NSLog(@"Resulted in Color %f, %f, %f", r, g, b);
  }
  else
      NSLog(@"Only found %d", n);  
*/

  NSLog(@"Control uses %@", [NSControl cellClass]);
  NSLog(@"ComboBox uses %@", [NSComboBox cellClass]);
  NSLog(@"Control uses %@", [NSControl cellClass]);
  
  [NSComboBox setCellClass: [NSComboBoxCell class]];
  NSLog(@"Control uses %@", [NSControl cellClass]);
  NSLog(@"ComboBox uses %@", [NSComboBox cellClass]);
  
  RELEASE(pool);
  return 0;
}

The output is (with the corrected version of ComboBox):

Apr 09 22:27:58 cell[2674] System color 'controlTextColor' has bad
string rep -
'0.000000 0.000000 0.000000'
Apr 09 22:27:58 cell[2674] System color 'disabledControlTextColor' has
bad string rep - '0.333000 0.333000 0.333000'
Apr 09 22:27:58 cell[2674] System color 'controlDarkShadowColor' has bad
string
rep - '0.000000 0.000000 0.000000'
Apr 09 22:27:58 cell[2674] Control uses NSCell
Apr 09 22:27:58 cell[2674] System color 'textBackgroundColor' has bad
string rep - '1.000000 1.000000 1.000000'
Apr 09 22:27:58 cell[2674] System color 'textColor' has bad string rep -
'0.000000 0.000000 0.000000'
Apr 09 22:27:58 cell[2674] ComboBox uses NSComboBoxCell
Apr 09 22:27:58 cell[2674] Control uses NSCell
Apr 09 22:27:58 cell[2674] Control uses NSCell
Apr 09 22:27:58 cell[2674] ComboBox uses NSComboBoxCell  

Ignore the last four line, as they are the expected output. This shows
that NSColor is not able to convert some string values into colours.
When I just add one NSLog line before the first access of any ComboBox
or Control, e.g. by uncommenting the last line before that, this error
messages vanish and everything works fine. 
>From this I think that the problem is caused by a missing initialization
of NSString, but how could that happen?

Any explanation of this phenomena is welcome

Fred




reply via email to

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