Re: Advice on document handling
Re: Advice on document handling
- Subject: Re: Advice on document handling
- From: John Brownie <email@hidden>
- Date: Tue, 10 Jun 2014 14:35:49 +1000
On Tue Jun 10 2014 13:14:51 GMT+1000 (PGT) Graham Cox wrote:
On 10 Jun 2014, at 11:28 am, John Brownie <email@hidden> wrote:
I think that the problem is likely to involve the fact that documents can be owned by both the bundle document class and the simple document class, and trying to save the same document may be leading to the problem.
But is it the same file?
Yes, it can be.
It's not clear from your description whether you have two different document objects managing the same 'unbundled' file, it sounds as if it's only the same file TYPE. I can't see that would cause a problem. But if there's a situation where you can have the same disk file managed by two different document objects, one bundled and the other not, that would probably be a problem.
The approach I took, which seemed like a good idea at the time, was to
extend the original capability to edit an unbundled document to allow
editing bundled versions. So the bundle editor shows a list of documents
with their metadata, and double-clicking a document in that list opens
an editor window, which currently has a separate NSDocument controlling
it, which is where I think the problem lies. I suspect that auto-save is
triggering a save through both the bundle class and the document class.
Do you save your unbundled file as a bundled file? Or does bundled/unbundled always remain distinct? If so the only way it could happen would be if you opened the raw file from within its package while the package itself was already open, which is really an error situation - so you might want to consider checking for that possibility if it's considered likely enough.
No, the unbundled file is stored as a plain file. However, it is
possible to either embed it in an existing bundle, or to convert it to a
bundled version, since the only way to have the metadata is in a bundle
(and I call it that since that's the extension).
I have a similar situation in my app actually, where I can open a 'raw' document file and one that embeds the exact same file type in a bundle (actually the term is 'package'). But I handle this using the same document class - the method -readFromURL:ofType:error: takes different pathways to deal with the file based on type. On save, the type again is used to only package the file that was previously packaged, raw stays raw. That said, having separate document classes shouldn't affect that, though in my case it doesn't make sense because all of the different files open the same UI, windows, data model, etc. I've not run into problems with deadlocks, though thinking about it I probably could if I forced it to open a file from inside an open package - I haven't bothered checking for that because I do consider it unlikely to occur by accident.
OK, that makes me think about the possibility of merging the document
classes and avoiding the problem. It will likely mean a long, hard look
at how I structure things, but it might be road to follow.
Thanks for the input.
John
--
John Brownie, email@hidden or email@hidden
Summer Institute of Linguistics | Mussau-Emira language, Mussau Is.
Ukarumpa, Eastern Highlands Province | New Ireland Province
Papua New Guinea | Papua New Guinea
_______________________________________________
Cocoa-dev mailing list (email@hidden)
Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden