« Return to Thread: Fix, Base, NSKeyValueCoding (SetValueForKey())

Fix, Base, NSKeyValueCoding (SetValueForKey())

by Georg Fleischmann-2 :: Rate this Message:

Reply to Author | View in Thread

Hi,

here is a fix for NSKeyValueCoding SetValueForKey() to prefer the key  
as is (without leading underscore) before trying with underscore (_key).

My problem: When loading a Nib file with a key named "infoPanel" for  
NSApplication, the value gets set to "_infoPanel" instead, which also  
exists in GNUstep.

Best wishes,
Georg Fleischmann


*** Source/NSKeyValueCoding.m.old 2009-02-28 14:31:08.000000000 +0800
--- Source/NSKeyValueCoding.m 2009-06-23 11:28:56.000000000 +0800
***************
*** 116,143 ****
         if ([[self class] accessInstanceVariablesDirectly] == YES)
    {
     buf[size+4] = '\0';
-  buf[3] = '_';
     buf[4] = lo;
!  name = &buf[3]; // _key
     if (GSObjCFindVariable(self, name, &type, &size, &off) == NO)
       {
         buf[4] = hi;
         buf[3] = 's';
         buf[2] = 'i';
!      buf[1] = '_';
!      name = &buf[1]; // _isKey
         if (GSObjCFindVariable(self,
    name, &type, &size, &off) == NO)
    {
     buf[4] = lo;
!  name = &buf[4]; // key
     if (GSObjCFindVariable(self,
       name, &type, &size, &off) == NO)
       {
         buf[4] = hi;
         buf[3] = 's';
         buf[2] = 'i';
!      name = &buf[2]; // isKey
         GSObjCFindVariable(self,
    name, &type, &size, &off);
       }
--- 116,143 ----
         if ([[self class] accessInstanceVariablesDirectly] == YES)
    {
     buf[size+4] = '\0';
     buf[4] = lo;
!  name = &buf[4]; // key
     if (GSObjCFindVariable(self, name, &type, &size, &off) == NO)
       {
         buf[4] = hi;
         buf[3] = 's';
         buf[2] = 'i';
!      name = &buf[2]; // isKey
         if (GSObjCFindVariable(self,
    name, &type, &size, &off) == NO)
    {
+  buf[3] = '_';
     buf[4] = lo;
!  name = &buf[3]; // _key
     if (GSObjCFindVariable(self,
       name, &type, &size, &off) == NO)
       {
         buf[4] = hi;
         buf[3] = 's';
         buf[2] = 'i';
!      buf[1] = '_';
!      name = &buf[1]; // _isKey
         GSObjCFindVariable(self,
    name, &type, &size, &off);
       }



_______________________________________________
Bug-gnustep mailing list
Bug-gnustep@...
http://lists.gnu.org/mailman/listinfo/bug-gnustep

 « Return to Thread: Fix, Base, NSKeyValueCoding (SetValueForKey())