I heard from a user of the Attachment Viewer today that when a large ZIP was selected the client appeared to hang. He explained that the attachment viewer was not even showing yet it looks like it still processed the selection. Well, he was right. After looking at the code, it was actually processing the ZIP file every time – whether the viewer was showing or not. So I made a simple change and he is checking it out (testing it for me). I did my small unit tests but I figured giving him a patch and testing his large ZIP file attachment would also be good – a second set of tests is always welcome in software. 🙂
So what did I do?
In the selectionChanged() event I had to determine if the view was visible or open. This was an interesting problem because the view itself does not contain this state. What I had to do was register the view with the workbench as an IPartListener2. Why the “2” and not just IPartListener? The key event we need is actually partHidden()!
The description of the event is here:
Notifies this listener that the given part is hidden or obscured by another part.
What I do is have a class level property named “_closed” and set it to true or false in the different events for IPartListener2. This allows me to not process the selection if its “_closed” and just return out of the selectionChanged() callback.
I scoured the SWT and Eclipse world and I could not see another way to do this so if anyone has any input please let me know. I will be updated the OpenNTF project with the fix in a few days. I am sure one of the Eclipse guru’s reading would know if this is correct or not.