<AWT Dev> [8] Review request for 8020038: [macosx] Incorrect usage of invokeLater() and likes in callbacks called via JNI from AppKit thread

Artem Ananiev artem.ananiev at oracle.com
Tue Jul 9 07:38:45 PDT 2013


On 7/8/2013 8:35 PM, Leonid Romanov wrote:
> I encountered the case of unset handlerContext while testing SwingSet3 Web Start app.  It is triggered by selecting SwingSet3->About from the global menu bar. Since SwingSet3 doesn't use eAWT, it doesn't register any handlers, so selecting "About" menu item just shows standard Cocoa About dialog. In the code, it is accomplished by the following snippet from   _AppEventDispatcher.dispatch:
>
>              if (localHandler == null) {
>                 performDefaultAction(event);
>              } else {
>                  performUsing(localHandler, event);
>              }
>
> _AppEventDispatcher.performDefaultAction() is an abstract method, implemented in _AboutDispacther (shows native about dialog ) and _QuitDispatcher (quits the app). So, in order to display default About dialog we have to do the dispatching, even though handlerContext hasn't been set.

Do I get it right, that About and Quit menu handlers are implemented in 
eAWT code, not in the application code, and in these and only these 
cases we call performDefaultAction() instead of performUsing()? Could we 
then write it the following way:

>      // handler hasn't been set
>      if (handlerContext == null) {
>          performDefaultAction(event);
>      } else {
>          SunToolkit.invokeLaterOnAppContext(handlerContext, r);
>      }

Thanks,

Artem

> On Jul 8, 2013, at 8:14 PM, Artem Ananiev <artem.ananiev at oracle.com> wrote:
>
>>
>> The changes look fine, except _AppEventDispatcher.dispatch(). Should we dispatch the event at all, in case handlerContext hasn't been set (or set to null, which should never happen)? I would say no.
>> /*=
>> Thanks,
>>
>> Artem
>>
>> On 7/8/2013 6:28 PM, Leonid Romanov wrote:
>>> Hello,
>>> Please review a fix for 8020038: [macosx] Incorrect usage of invokeLater() and likes in callbacks called via JNI from AppKit thread, As you aware, recent AppContext usage change in 7u25 exposed a number of AppContext related issues in our code. This particular bug focuses on the incorrect invokeLater() and likes usage on OS X. This issue has been discussed in the following thread:
>>> http://mail.openjdk.java.net/pipermail/macosx-port-dev/2013-June/005788.html
>>>
>>> Bug: http://bugs.sun.com/view_bug.do?bug_id=8020038 (might not be available yet)
>>> Webrev: http://cr.openjdk.java.net/~leonidr/8020038/webrev.00/
>>>
>>> Thanks,
>>> Leonid.
>>>
>>>
>>>
>


More information about the awt-dev mailing list