bugGNUstep - Bugs: bug #36967, Manual Key Value Observing Not...

Group
 
 

bug #36967: Manual Key Value Observing Not Using Passed Objects

Submitter:  Robin <rdemet>
Submitted:  Thu 26 Jul 2012 06:55:31 PM UTC
   
 
Category:  Base/Foundation Severity:  3 - Normal
Item Group:  None Status:  Fixed
Privacy:  Public Assigned to:  None
Open/Closed:  In Test
* Mandatory Fields

Add a New Comment Rich Markup
   

Thu 02 Aug 2012 08:20:58 PM UTC, comment #2: 

Hi Richard, I realise that my original posting was a bit short on details so I have put together a short program (attached) to show the behaviour under OSX Lion when posting manual kvo notifications.

Here's the output under OSX. I can also compare with your modifications under Linux when I get a chance.

However the first thing I notice is that the OSX implementation does seem to query the keyPath property for the willChangeValueForKey:  but then uses the passed object for doing whatever set delta operation you specify.

Output on OSX is :
2012-08-02 22:17:13.724 kvohow[4207:303] >>DataClass setValue '(null)' now renamed to 'initial value'
2012-08-02 22:17:13.727 kvohow[4207:303] >>DataClass setValue 'initial value' now renamed to 'changed value'
2012-08-02 22:17:13.729 kvohow[4207:303] >>DataClass 'value' property has been queried.
2012-08-02 22:17:13.817 kvohow[4207:303] Observer: keyPath 'value' change '{
    kind = 1;
    notificationIsPrior = 1;
    old = "changed value";
}'
2012-08-02 22:17:13.818 kvohow[4207:303] >>DataClass setValue 'changed value' now renamed to 'observed value'
2012-08-02 22:17:13.819 kvohow[4207:303] >>DataClass 'value' property has been queried.
2012-08-02 22:17:13.820 kvohow[4207:303] Observer: keyPath 'value' change '{
    kind = 1;
    new = "observed value";
    old = "changed value";
}'
2012-08-02 22:17:13.822 kvohow[4207:303]   -- Manual Notifications -- 
2012-08-02 22:17:13.823 kvohow[4207:303] ** addToSet - willChangeValueForKey
2012-08-02 22:17:13.824 kvohow[4207:303] >>DataClass 'data' property has been queried.
2012-08-02 22:17:13.825 kvohow[4207:303] Observer: keyPath 'data' change '{
    kind = 2;
    new = "{(\n    \"A New Object\"\n)}";
    notificationIsPrior = 1;
}'
2012-08-02 22:17:13.826 kvohow[4207:303] ** addToSet - didChangeValueForKey
2012-08-02 22:17:13.827 kvohow[4207:303] Observer: keyPath 'data' change '{
    kind = 2;
    new = "{(\n    \"A New Object\"\n)}";
}'
2012-08-02 22:17:13.828 kvohow[4207:303] * addToSet COMPLETE ***************
2012-08-02 22:17:13.829 kvohow[4207:303] ** replaceInSet - willChangeValueForKey
2012-08-02 22:17:13.830 kvohow[4207:303] >>DataClass 'data' property has been queried.
2012-08-02 22:17:13.831 kvohow[4207:303] Observer: keyPath 'data' change '{
    kind = 3;
    notificationIsPrior = 1;
    old = "{(\n    \"A New Object\"\n)}";
}'
2012-08-02 22:17:13.832 kvohow[4207:303] ** replaceInSet - didChangeValueForKey
2012-08-02 22:17:13.832 kvohow[4207:303] Observer: keyPath 'data' change '{
    kind = 3;
    old = "{(\n    \"A New Object\"\n)}";
}'
2012-08-02 22:17:13.833 kvohow[4207:303] * replaceInSet COMPLETE ***************
2012-08-02 22:17:13.834 kvohow[4207:303] ** removeFromSet - willChangeValueForKey
2012-08-02 22:17:13.835 kvohow[4207:303] >>DataClass 'data' property has been queried.
2012-08-02 22:17:13.835 kvohow[4207:303] Observer: keyPath 'data' change '{
    kind = 3;
    notificationIsPrior = 1;
    old = "{(\n    \"Something else\"\n)}";
}'
2012-08-02 22:17:13.836 kvohow[4207:303] ** removeFromSet - didChangeValueForKey
2012-08-02 22:17:13.837 kvohow[4207:303] Observer: keyPath 'data' change '{
    kind = 3;
    old = "{(\n    \"Something else\"\n)}";
}'
2012-08-02 22:17:13.838 kvohow[4207:303] * removeFromSet COMPLETE ***************

Rgds,
Robin


(file #26308)

Robin <rdemet>
Fri 27 Jul 2012 07:01:10 PM UTC, comment #1: 

Thanks ... I've modified the code to do that ... please give it a try and let us know if it behaves the same way as OSX now.

Richard Frith-Macdonald <CaS>
Group Member
Thu 26 Jul 2012 06:55:31 PM UTC, original submission:  


Looking at the implementation of NSKeyValueObserving.m
(lines 1816, 1846)
 
.. willChangeValueForKey: (NSString*)aKey
       withSetMutation: (NSKeyValueSetMutationKind)mutationKind
  usingObjects:(NSSet*)objects

and  

... didChangeValueForKey: (NSString*)aKey
      withSetMutation: (NSKeyValueSetMutationKind)mutationKind
usingObjects: (NSSet*)objects

I notice that the NSSet* object parameter is not being used, but instead the property 'aKey' is being requested each time.

Should this implementation not use the passed NSSet* of objects when deciding on the delta to report to the observers?

I have code running on OSX Lion that appears to do this, and from the function signatures I expect that's the intended behaviour.



Robin <rdemet>

 

(Note: upload size limit is set to 16384 kB, after insertion of the required escape characters.)

Attach Files:
   
   
Comment:
   

Attached Files
file #26308:  main.m added by rdemet (5KiB - application/octet-stream - small test app to show OSX manual kvo behaviour)

 

Depends on the following items: None found

Items that depend on this one: None found

 

Carbon-Copy List
  • -email is unavailable- added by CaS (Posted a comment)
  • -email is unavailable- added by rdemet (Submitted the item)
  •  

    There are 0 votes so far. Votes easily highlight which items people would like to see resolved in priority, independently of the priority of the item set by tracker managers.

    Only logged-in users can vote.

     

    Follow 3 latest changes.

    Date Changed by Updated Field Previous Value => Replaced by
    2012-08-02 rdemet Attached File- Added main.m, #26308
    2012-07-27 CaS StatusNone Fixed
        Open/ClosedOpen In Test

    Back to the top

    Powered by Savane 3.13-02a9.
    Corresponding source code