[rfc][icedtea-web][policyeditor] Invoking runnables on EDT
Andrew Azores
aazores at redhat.com
Tue Jun 24 19:08:47 UTC 2014
Hi,
PolicyEditor has a few odd cases with window resizing and with "changes
made" being marked as true when the editor is opened without any
arguments. Both of these cases arise because although the EDT is the
current thread when these actions are taken, they are (for safety, in
case they are invoked by a non-EDT thread) wrapped in a
SwingUtilities.invokeLater call. In the case of "changes made", this
leads to addNewCodebase("") (adding the default all-applets codebase)
marking "changes made" as true when the PolicyEditor is instantiated,
even though the constructor has setChangesMade(false) immediately after
the addNewCodebase call. This happens because the addNewCodebase() call
updates the UI and so its main functionality is within an invokeLater -
including the setChangesMade(true) call. Although a simple fix would be
to pull the setChangesMade out of the invokeLater block, this would mean
that the editor could potentially report changes made before the UI
updates, which I'd like to avoid. Another solution would be to also wrap
the setChangesMade(false) in the constructor in yet another invokeLater,
but this is messy, and as this doesn't touch any UI elements it's also
unnecessary. And another solution, which this patch implements, is to
use a helper method, here called invokeRunnableOrEnqueueLater, which
replaces SwingUtilities.invokeLater in the PolicyEditor. If the current
thread is already the EDT then it calls Runnable#run() directly on its
sole parameter. If the current thread is not the EDT then the runnable
argument is passed along to SwingUtilities.invokeLater to be enqueued
and processed as usual.
A similar technique was used for
updateCheckboxes/updateCheckboxesInvokeAndWait/updateCheckboxesImpl,
although in that case it was SwingUtilities.invokeAndWait rather than
invokeLater. These have been slightly refactored to go along with the
new method.
Thanks,
--
Andrew A
-------------- next part --------------
A non-text attachment was scrubbed...
Name: policyeditor-invoke-runnable-edt.patch
Type: text/x-patch
Size: 6162 bytes
Desc: not available
URL: <http://mail.openjdk.java.net/pipermail/distro-pkg-dev/attachments/20140624/5c887955/policyeditor-invoke-runnable-edt-0001.patch>
More information about the distro-pkg-dev
mailing list