fix: import file only once to document#1158
Conversation
|
Hi, |
|
One question about this PR: It make sense to let only one adapter to import the document. In other words, with a example: The PR fixes the #1156 issue because the OpenBoard/src/core/UBDocumentManager.cpp Lines 94 to 103 in 3b38085 So I try to answer to my question: But how we can be sure is the best adapter for this format ? |
Yes, exactly. This is a very good question, and I also asked it to myself. To make the answer a little bit more generic: To find the right adapter when multiple adapters would offer to handle a file format we can have two approaches:
The current code guarantees a fixed order, so the second approach works well. (Side note: a registration approach where each adapter offers its capabilities to the document manager in an unspecified order would require the first approach.) If we care to order more specific adapters before more generic ones, then this solves the problem. The current sequence already fulfills this condition. And as you said, PDF is currently the only one where this occurs. And the image adapter is the only one where the list of supported file formats can vary. All others return a fixed string list. |
|
Shall I rebase this branch, too? I must admit, I do not fully understand what the merging of |
|
yes, please |
- when importing a file to the board, the file was offered to all import adapters - if multiple import adapters support the same file extension, then the file was imported multiple times - this was especially true for pdf documents, where in some environments also the image adapter supported rendering a pdf document (preview image of first page) - this commit leaves the loop iterating over the adapters once one of them has successfully imported the file
d194c68 to
9db4d02
Compare
done |

This PR fixes #1156 where the first page of a PDF document was repeated at the end when importing the PDF by dropping it to the board.
@sebojolais: could you test this PR whether it fixes the problem for you?