• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: Snapshot access NPE
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Snapshot access NPE


  • Subject: Re: Snapshot access NPE
  • From: OC <email@hidden>
  • Date: Fri, 27 Feb 2015 09:00:47 +0100

Chuck,

On 27. 2. 2015, at 5:51, Chuck Hill <email@hidden> wrote:

    void validateForSave {
        super.validateForSave()
        fixArchivedButReallyUnchangedItemsFromSnapshot() // <=== this is line 980 ===

“fix” sounds like “change EO object state”.  Note carefully that the name of the method is validateForSave, not validateForSaveAndChangeDataBehindEOFsBack.  EO state should not change during validation.

Hmmm, this might be the culprit.

The trick is, this being my old application, I am saving serialized NSDictionaries to BLOBs, and I've found there were *lots* of superfluous updates, which I have tracked to the sad fact that serialization (through ObjectOutput/InputStream) tends to create different NSDatas from same objects. Thus, I've aded essentially this code:

===
    void fixArchivedButReallyUnchangedItemsFromSnapshot {
        NSDictionary ss=this.editingContext().committedSnapshotForObject(this)
        NSDictionary d=this.changesFromSnapshot(ss)
            d.each { String k,v ->
                if (k.hasSuffix('_archivedNSObject')) { // all my BLOB attributes have this kind of name
                    def vd=Archivation.objectFromArchivedData(v) // Archivation uses ObjectOutput/InputStream to...
                    def ssvd=Archivation.objectFromArchivedData(ss[k]) // ...turn objects to NSData and back
                    if (vd==ssvd) this.takeValueForKey(ss[k],k)
                }
            }
        }
    }
===

and it did fix those superfluous updates all right... but perhaps it brought another problems?

I'll try to move this out from validateForSave, just before saveChanges...

Thanks,
OC


 _______________________________________________
Do not post admin requests to the list. They will be ignored.
Webobjects-dev mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:

This email sent to email@hidden

  • Follow-Ups:
    • Re: Snapshot access NPE
      • From: Chuck Hill <email@hidden>
References: 
 >Snapshot access NPE (From: OC <email@hidden>)
 >Re: Snapshot access NPE (From: Chuck Hill <email@hidden>)

  • Prev by Date: Re: in another EC, when objects transferred through GIDs, owning relationship does not delete objects?!?
  • Next by Date: Re: D2W Rules
  • Previous by thread: Re: Snapshot access NPE
  • Next by thread: Re: Snapshot access NPE
  • Index(es):
    • Date
    • Thread