letsfindaway / OpenBoard

I'm using this fork to contribute features and fixes to the upstream project. In order to create good pull requests, I'm rebasing my feature branches, squashing and reordering commits, etc. If you fork this repository be aware that my development branches may rewrite history without prior notice.
http://openboard.ch/
GNU General Public License v3.0
9 stars 0 forks source link

[Architecture] Harmonize copying a scene #198

Open letsfindaway opened 2 days ago

letsfindaway commented 2 days ago

In the source code I found three different implementations for copying a scene:

Note: Copying the objects in the first and third implementation was introduced with commit 38032fb42dd3d352f66f37dd76ecbedab2a43565 in April 2019 to fix an issue where images could get lost.

Depending on the method, the UUID of copied objects is changed or not. We have also seen, that sceneDeepCopy() fails to update the data property related to z level.

I propose

Copy file or scene?

I think the answer very much depends on how deep we have to go into the details while copying. But finding the referenced objects already needs a deep understanding of the file and so I tend to a scene level approach.

As far as I can see the UBForeighnObjectsHandler tries to stay at the file level for the price, that it implements another SVG parser besides the UBSvgSubsetAdaptor. This is very dangerous when doing updates to the file format which would also affect the foreign objects.

letsfindaway commented 1 day ago

See the note above: as analyzed in #193 this function is currently unreachable and not used.

UBForeighnObjectsHandler

This class and associated helper classes are created to some supporting stuff when dealing with documents. When you look at the functions it has there are only a few:

copyPage

This function, which is most relevant for us, is first forwarded two times: first to a UBForeighnObjectsHandlerPrivate and then further to a PageCopier: here the function has three steps:

So what does cureIdsFromSvgDom() do?

Si in the end the result is quite similar to UBPersistenceManager::duplicateDocumentScene(), however with different implementations:

I tend to use the scene based approach, because then the UBSvgSubsetAdaptor is the only class which needs to know about SVG. This would mean:

Together with this I would also like to ask when it is necessary to change the UUID of the copy. I do not see a good reason for this. If I copy a file, why should it not have the same UUID as before? It is still the same file contents!

letsfindaway commented 18 hours ago

Change UUID of objects when copying?

There a PROs and CONs for changing the UUID when copying a scene.

PRO changing UUID, CON changing UUID