[rfc][icedtea-web][policyeditor] Reduced usage of weak references

Omair Majid omajid at redhat.com
Wed Jun 11 18:04:12 UTC 2014


Hi,

Thanks for the cleanup!

* Andrew Azores <aazores at redhat.com> [2014-06-11 13:55]:
> +++ b/netx/net/sourceforge/jnlp/security/policyeditor/PolicyEditor.java
> @@ -173,6 +173,13 @@ public class PolicyEditor extends JPanel
>              addCodebaseButton = new JButton(), removeCodebaseButton = new JButton();
>      private final JFileChooser fileChooser;
>      private CustomPolicyViewer cpViewer = null;
> +
> +    /**
> +     * See showChangesSavedDialog. This weak reference is needed because there is a modal child
> +     * dialog which can sometimes appear after the editor has been closed and disposed. In this
> +     * case, its parent should be set to 'null', but otherwise the parent should be the editor
> +     * so that the dialog is modal.
> +     */
>      private final WeakReference<PolicyEditor> weakThis = new WeakReference<>(this);

In this case, please call it something more appropriate, Like
'parentDialog', and change the reference type to Window. It makes sense
that the code that expects a parent uses null whereas `weakThis` seems
like a really odd sort of a name.

>      private void showChangesSavedDialog() {
> +        // This dialog is often displayed when closing the editor, and so PolicyEditor
> +        // may already be disposed when this dialog appears. Give a weak reference so
> +        // that this dialog doesn't prevent GC of the editor

Is preventing GC in this such a bad thing? Presumably, this will only be
an issue for a few seconds, right? Because then the dialog goes away.

Thanks,
Omair

-- 
PGP Key: 66484681 (http://pgp.mit.edu/)
Fingerprint = F072 555B 0A17 3957 4E95  0056 F286 F14F 6648 4681


More information about the distro-pkg-dev mailing list