-
Notifications
You must be signed in to change notification settings - Fork 428
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix: import file only once to document #1158
base: dev
Are you sure you want to change the base?
fix: import file only once to document #1158
Conversation
- 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
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. |
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?