> JDK-6726690 fixed the issue whereby
> 
>> SwingUtilities.replaceUIInputMap() and SwingUtilities.replaceUIActionMap() 
>> were not actually removing/uninstalling previously installed maps
>>  contrary to what their Javadoc indicates, if null is passed as 
>> uiInputMap/uiActionMap
> 
>  by adding map.clear() to the traversal whenever the replacement argument was 
> null.
>  So, the old bindings were erased, however, it turned out it also deleted 
> bindings belonging to the application.
>  
>  Basically, map traversal starts at the component’s own application map so 
> consequently, the new clearing operation deletes application entries _before_ 
> reaching the UI-owned parent.
>  
>  The methods have no information that a particular entry belongs to the 
> application; so map.clear() simply clears whichever map it is currently 
> visiting.
>  This becomes a regression because Swing itself calls these removal methods 
> `replaceUIInputMap()`, `replaceUIActionMap()` during normal UI changes.
>  When `updateComponentTreeUI()` updates a component, Swing uninstalls its old 
> UI delegate and installs the current look-and-feel delegate.
>  During uninstallation, delegates remove their keyboard bindings by calling 
> `replaceUIInputMap(..., null)` and `replaceUIActionMap(..., null)`.
>  With unconditional clearing, those cleanup calls erase application shortcuts 
> too. 
> That is the failure reported here.
>  
>  This patch introduces a temporary record of which components are undergoing 
> UI installation or uninstallation
>  The existing callback calls in JComponent go through newly added helper 
> methods in SwingUtilities2.
> Before installing or uninstalling the component’s look-and-feel 
> implementation, 
> `installUI()` records which component is being updated. 
> After the operation finishes, `changeUI()` restores the previous record. 
> ` isChangingUI()` then consult that record before clearing a map, that is, 
> checks whether the component has an active UI-change context.
>  `SwingUtilities.replaceUIInputMap()` and `replaceUIActionMap()` use this to 
> decide whether to skip map.clear().
>  
>  So, basically, when `updateComponentTreeUI()` installs or uninstalls a 
> component’s look-and-feel implementation, the helper marks that component as 
> being updated and if the look-and-feel code requests removal of its UI maps 
> during this process, the replacement methods skip clearing the maps. This 
> preserves the application’s custom key bindings
>  The explicit removal calls in the JDK-6726690 test occur when no such update 
> is in progress. The replacement methods...

Prasanta Sadhukhan has updated the pull request incrementally with one 
additional commit since the last revision:

  Route Nimbus keyboard action and Jlist serialization via SwingUtilities2 
helpers

-------------

Changes:
  - all: https://git.openjdk.org/jdk/pull/34034/files
  - new: https://git.openjdk.org/jdk/pull/34034/files/46bb9f26..2967b543

Webrevs:
 - full: https://webrevs.openjdk.org/?repo=jdk&pr=34034&range=01
 - incr: https://webrevs.openjdk.org/?repo=jdk&pr=34034&range=00-01

  Stats: 171 lines in 4 files changed: 159 ins; 5 del; 7 mod
  Patch: https://git.openjdk.org/jdk/pull/34034.diff
  Fetch: git fetch https://git.openjdk.org/jdk.git pull/34034/head:pull/34034

PR: https://git.openjdk.org/jdk/pull/34034

Reply via email to