Community
Participate
Working Groups
In RCP client code I frequently see if(mywidget!=null && !mywidget.isDisposed()) {// do stuff}, especially in asynchronous calls. Maye we should add a static util method to JFace to check this, for example boolean isAvailable(Widget);
Indeed that construct is used all over the place. From a quick scroll through the code some (non-static) functions that offer similar functionality, with names like 'isValid', 'okToUse' and 'exist' (e.g. menuExist). Places that already implement the static method (among others?): org.eclipse.ui.internal.ide.application.IDEApplication.isValidShell(Shell) org.eclipse.jface.internal.text.link.contentassist.Helper2.okToUse(Widget) org.eclipse.jface.text.contentassist.Helper.okToUse(Widget)
Thanks Rolf for the check. Which name to you like? I like isValid as it is relatively short. I would suggest to put the check into JFace.
New Gerrit change created: https://git.eclipse.org/r/c/platform/eclipse.platform.ui/+/168625
New Gerrit change created: https://git.eclipse.org/r/c/platform/eclipse.platform.ui/+/169007
Gerrit change https://git.eclipse.org/r/c/platform/eclipse.platform.ui/+/168625 was merged to [master]. Commit: http://git.eclipse.org/c/platform/eclipse.platform.ui.git/commit/?id=10ee4503e2b133fbe53b67f8d3ef1f93865f3b68
Rolf, shall we use this bug to replace some of the old usages or shall we do this via a new bug?
(In reply to Lars Vogel from comment #6) > Rolf, shall we use this bug to replace some of the old usages or shall we do > this via a new bug? I don't have a preference. A quick search on the regexp 'null.*isDisposed()' returned 458 matches, which gives an indication for the amount of work. If replacing all cases is desired, it will be probably too much for a single bug report.
This created build warning due do javadoc error: ../../../eclipse.platform.ui/bundles/org.eclipse.jface/src/org/eclipse/jface/util/Util.java:701: warning: no description for @param * @param widget ^ 1 warning
New Gerrit change created: https://git.eclipse.org/r/c/platform/eclipse.platform.ui/+/169272
New Gerrit change created: https://git.eclipse.org/r/c/platform/eclipse.platform.text/+/169275
Gerrit change https://git.eclipse.org/r/c/platform/eclipse.platform.ui/+/169272 was merged to [master]. Commit: http://git.eclipse.org/c/platform/eclipse.platform.ui.git/commit/?id=5fbd42a5df9c62872739bade37f269ceb239a493
Gerrit change https://git.eclipse.org/r/c/platform/eclipse.platform.text/+/169275 was merged to [master]. Commit: http://git.eclipse.org/c/platform/eclipse.platform.text.git/commit/?id=43aa85f0d63da0f2101b0cd7d7ae55234cf95e6f
New Gerrit change created: https://git.eclipse.org/r/c/www.eclipse.org/eclipse/news/+/169341
Gerrit change https://git.eclipse.org/r/c/www.eclipse.org/eclipse/news/+/169341 was merged to [master]. Commit: http://git.eclipse.org/c/www.eclipse.org/eclipse/news.git/commit/?id=971263f6cc94a55c3ff863be78c308e666bc0281
I also this as we have now this method and it is used in our code. The remaining places can be adjusted with bug reference, if someone find the time and has the interest of doing this.