[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [Newsgroup Home]
[news.eclipse.platform.swt] When do ViewParts get disposed?

I have a view extending a org.eclipse.ui.part.ViewPart. For various reasons this view needs to be a singleton to avoid, that two or more views try to change the same model, thereby interfeering with each other.

Thus, in its constructor it checks whether it's the only instance by checking a variable "singleton". If that variable is already set it throws an exception, if not, it sets it to itself.
In its dispose() method - after some other cleanup - it sets that variable to null again, i.e. after a proper dispose() another instance could be created.


When I close the view and re-open it again I always get the exception signalling that there is another alive instance. So, apparently eclipse does not call dispose() after closing that ViewPart (even if this is the only use, i.e. it got opened only in the current perspective). This causes the problem, that - if a user ever closes the view - and later wants to re-open it again - things fail, because another view can not be recreated unless the other instance has been disposed. The only work-around for this is to restart eclipse :-(

How can I overcome this? Can one somehow tell eclipse to dispose that ViewPart after closing it?

Michael