
2014/1/21 Martin Owens <doctormo@...400...>:
Hey developers,
This is the model I'm going to implement for documents to reference other documents:
SPDocument { GSList *child_documents; SPDocument *parent_document;
// Parent of parents until parent == NULL; SPDocument *getRootDocument(); }
1. What if we edit 2 documents in one instance of Inkscape, and both of those documents refer to a third? We should be able to avoid creating an extra copy of the SP tree in that case. On the other hand, it's not clear to me what would be the preferred behavior in the following scenario:
1. Open a.svg, which refers to common.svg 2. Modify common.svg 3. Open b.svg, which also refers to common.svg
Are we supposed to display different contents of common.svg in windows for a.svg and b.svg, reflecting their different contents at opening time, or should the displayed content of common.svg change when the file content is modified on disk?
My opinion is that all external links should be updated whenever the referred resource changes, with the exception of the currently edited document - there should be a notification that it changed on disk, but no automatic reloading. If the currently edited document is referred to in another window, then that window should change to reflect its current on-disk state.
2. Do not use GSList and GListin new code, ever. Not only are they type-unsafe, they are implemented as plain lists without sentinel nodes, so append is O(N) even on a doubly-linked list. For a much better alternative, see src/display/drawing-item.h - I used a Boost intrusive list to implement a tree hierarchy. Another option is boost::ptr_list, which is suitable if the children should be destroyed along with the parent.
3. If child_documents and parent_document are supposed to be private, they should be called _child_documents and _parent_document.
4. Inkscape should detect cyclic references and display an error image in the place of references back to the root document (e.g. the one being edited).
Regards, Krzysztof