• 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: Chuck Hill <email@hidden>
  • Date: Fri, 27 Feb 2015 22:06:15 +0000
  • Thread-topic: Snapshot access NPE

Yes, I’d move that out of there.  Isn’t there a willSave() method in Wonder’s EOs?  That seems like a good place for this.


On 2015-02-27, 12:00 AM, "OC" wrote:

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

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

  • Prev by Date: Re: maven.wocommunity.org is down
  • Next by Date: Re: No template found for component Main
  • Previous by thread: Re: Snapshot access NPE
  • Next by thread: No template found for component Main
  • Index(es):
    • Date
    • Thread