Workaround for double clicking item bug #1217
Closed
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This is a workaround for bug #893, where if you double click an item that opens in the viewer, it opens in a way that the viewer can't close. It works for the Viewer for Images, Videos, and PDFs for sure. I didn't test audio, but it probably works for it as well.
The main cause of the issue is that when a file is double clicked, the file is opened twice. However, something weird occurs when this happens. openFile() is only called once, while close() and cleanup() are immediately called. What I'm guessing happens is that the original file loads, and is closed somehow, followed by the second file opening. I'm not sure which of those files calls openFile() and which doesn't. One result of this though is that when the second file is closed, close() is called, but cleanup() is not. This patch ensures that it is called, which resolves the issue.
There are still some cases where the double clicking can cause the black background of the viewer to not appear (to get this to happen, you have to double click, but put some spaces between the clicks that are a part of the double click, it's difficult to get the timing right, so try it a few times). But this at least solves the one issue.
This is not really meant to be a permanent workaround probably. There are better things to do then run cleanup(), but I can't set up my development environment well enough to test it. But this is suitable for now.
Signed-off-by: Michael Pope michael.pope.email@gmail.com