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.
The drop events are arriving at UBBoardView::dropEvent.
They are forwarded to UBBoardController::processMimeData, if they come from outside (not a UBThumbnailWidget, QWebEngineView or QListView).
Any files dropped to the board go to the hasUrls branch and are then passed to UBBoardController::downloadURL.
Here we create a description and pass it to UBDownloadManager::addFileToDownload.
After some processing of the download list we come to UBDownloadManager::startFileDownload, which starts an asynchronous copy in a separate thread executed at UBAsyncLocalFileDownloader::run.
Here a destination directory is chosen for video and audio, but not for PDF. Also a UUID is created.
Actual copying of the file is left to UBPersistenceManager::addFileToDocument.
Here the file is copied to the document's root directory.
Back in UBAsyncLocalFileDownloader::run, signal_asyncCopyFinished is emitted, which is processed in UBBoardController::downloadFinished.
Here we have a large switch for several mime types and finally process the PDF mime type at line 1428ff.
This now calls UBDocumentManager::addFilesToDocument, which searches an import adapter to handle the document.
The PDF import adapter is page based, i.e. it adds more pages to the document. Another UUID is created here.
The import adapter is asked for a folder to copy. This returns objects.
As it is non-empty, UBPersistenceManager::addFileToDocument is invoked again to copy the file to objects.
The document is then imported and the scenes are created for each page of the PDF document.
For audio and video, the UBBoardController::downloadFinished directly calls the UBPersistenceManager::addFileToDocument, so we have duplicates here, too.
Also raster and vector images are persisted here, so the initial copy by the download manager is not needed.
I think that the UBDownloadManager should consider where to place the files and whether copy is needed at all. As everything is persisted later, the download manager should probably
not copy the document, if the URL points to a local file,
download to a tmp folder, if the URL points to a network location.
To solve issue https://github.com/OpenBoard-org/OpenBoard/issues/671, problem 1 I analyzed the program flow when dropping an object on the board:
UBBoardView::dropEvent
.UBBoardController::processMimeData
, if they come from outside (not aUBThumbnailWidget
,QWebEngineView
orQListView
).hasUrls
branch and are then passed toUBBoardController::downloadURL
.UBDownloadManager::addFileToDownload
.UBDownloadManager::startFileDownload
, which starts an asynchronous copy in a separate thread executed atUBAsyncLocalFileDownloader::run
.UBPersistenceManager::addFileToDocument
.UBAsyncLocalFileDownloader::run
,signal_asyncCopyFinished
is emitted, which is processed inUBBoardController::downloadFinished
.switch
for several mime types and finally process the PDF mime type at line 1428ff.UBDocumentManager::addFilesToDocument
, which searches an import adapter to handle the document.objects
.UBPersistenceManager::addFileToDocument
is invoked again to copy the file toobjects
.UBBoardController::downloadFinished
directly calls theUBPersistenceManager::addFileToDocument
, so we have duplicates here, too.I think that the
UBDownloadManager
should consider where to place the files and whether copy is needed at all. As everything is persisted later, the download manager should probablytmp
folder, if the URL points to a network location.The problematic code is probably here: https://github.com/letsfindaway/OpenBoard/blob/fa9efeb8179e693cd7e6e6dcffe828e90c408303/src/board/UBBoardController.cpp#L1085-L1120 For local files we should always call
downloadFinished
and never copy the file here, as the persistence is managed there.