/hg/icedtea-web: Fix PolicyEditor duplicate entries when launche...

aazores at icedtea.classpath.org aazores at icedtea.classpath.org
Tue Jun 17 21:38:22 UTC 2014


changeset e665c266455c in /hg/icedtea-web
details: http://icedtea.classpath.org/hg/icedtea-web?cmd=changeset;node=e665c266455c
author: Andrew Azores <aazores at redhat.com>
date: Tue Jun 17 17:38:12 2014 -0400

	Fix PolicyEditor duplicate entries when launched from dialog

	2014-06-17  Andrew Azores  <aazores at redhat.com>

		* netx/net/sourceforge/jnlp/security/policyeditor/PolicyEditor.java
		(openAndParsePolicyFile): check if listModel already contains an element
		before adding a potential duplicate
		(addNewCodebase): perform the check for if the codebase is a duplicate
		when actually adding the codebase to the listModel, rather than beforehand
		and updating the UI in an invokeLater, which can cause a race


diffstat:

 ChangeLog                                                         |   9 +++++
 netx/net/sourceforge/jnlp/security/policyeditor/PolicyEditor.java |  18 ++++-----
 2 files changed, 17 insertions(+), 10 deletions(-)

diffs (54 lines):

diff -r cfd3501b1cdf -r e665c266455c ChangeLog
--- a/ChangeLog	Tue Jun 17 17:21:54 2014 -0400
+++ b/ChangeLog	Tue Jun 17 17:38:12 2014 -0400
@@ -1,3 +1,12 @@
+2014-06-17  Andrew Azores  <aazores at redhat.com>
+
+	* netx/net/sourceforge/jnlp/security/policyeditor/PolicyEditor.java
+	(openAndParsePolicyFile): check if listModel already contains an element
+	before adding a potential duplicate
+	(addNewCodebase): perform the check for if the codebase is a duplicate
+	when actually adding the codebase to the listModel, rather than beforehand
+	and updating the UI in an invokeLater, which can cause a race
+
 2014-06-17  Andrew Azores  <aazores at redhat.com>
 
 	Some PolicyEditor logic extracted into new class PolicyEditorController to
diff -r cfd3501b1cdf -r e665c266455c netx/net/sourceforge/jnlp/security/policyeditor/PolicyEditor.java
--- a/netx/net/sourceforge/jnlp/security/policyeditor/PolicyEditor.java	Tue Jun 17 17:21:54 2014 -0400
+++ b/netx/net/sourceforge/jnlp/security/policyeditor/PolicyEditor.java	Tue Jun 17 17:38:12 2014 -0400
@@ -732,18 +732,14 @@
         } else {
             model = codebase;
         }
-        final boolean existingCodebase = policyEditorController.addCodebase(codebase);
-        if (!existingCodebase) {
-            SwingUtilities.invokeLater(new Runnable() {
-                @Override
-                public void run() {
-                    listModel.addElement(model);
-                }
-            });
-        }
+        policyEditorController.addCodebase(codebase);
         SwingUtilities.invokeLater(new Runnable() {
             @Override
             public void run() {
+                if (!listModel.contains(model)) {
+                    listModel.addElement(model);
+                    setChangesMade(true);
+                }
                 list.setSelectedValue(model, true);
                 updateCheckboxes(codebase);
             }
@@ -1274,7 +1270,9 @@
                     } else {
                         model = codebase;
                     }
-                    listModel.addElement(model);
+                    if (!listModel.contains(model)) {
+                        listModel.addElement(model);
+                    }
                 }
                 addNewCodebase("");
                 progressIndicator.setVisible(false);


More information about the distro-pkg-dev mailing list