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

 
 

You are not allowed to post comments on this tracker with your current authentication level.

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

Submitted by:  Robin <rdemet>
Submitted on:  Thu 26 Jul 2012 06:55:31 PM UTC  
 
Category: Base/FoundationSeverity: 3 - Normal
Item Group: NoneStatus: Fixed
Privacy: PublicAssigned to: None
Open/Closed: In Test

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>
Project 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>

 

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
  • -unavailable- added by CaS (Posted a comment)
  • -unavailable- added by rdemet (Submitted the item)
  •  

    Do you think this task is very important?
    If so, you can click here to add your encouragement to it.
    This task has 0 encouragements so far.

    Only logged-in users can vote.

     

    Please enter the title of George Orwell's famous dystopian book (it's a date):

     

     

    Follow 3 latest changes.

    Date Changed By Updated Field Previous Value => Replaced By
    Thu 02 Aug 2012 08:20:58 PM UTCrdemetAttached File-=>Added main.m, #26308
    Fri 27 Jul 2012 07:01:10 PM UTCCaSStatusNone=>Fixed
      Open/ClosedOpen=>In Test

    Back to the top


    Powered by Savane 3.1-cleanup1