On Mon, 27 Apr 2026 21:06:02 GMT, Alexander Zvegintsev <[email protected]> 
wrote:

>> Phil Race has updated the pull request incrementally with one additional 
>> commit since the last revision:
>> 
>>   7186009
>
> src/java.desktop/macosx/native/libawt_lwawt/awt/CFileDialog.m line 133:
> 
>> 131:         [thePanel setDelegate:self];
>> 132:         inModalLoop = YES;
>> 133:         fPanelResult = [thePanel runModalForDirectory:fDirectory 
>> file:fFile];
> 
> At this point, is it possible that someone has already requested disposal, 
> yet we are still going to show the dialog?
> 
> Perhaps we can add a new `!isDisposeRequested` check here.

if they call dispose from another thread at around the same time, what do they 
expect  to happen ?
The show to never happen ? That would seem wrong. If it isn't showing dispose() 
basically does nothing.
Basically you can't dispose it if hasn't been shown

And an app  can do
  while (true) {
  dispose()
  show();
  dispose();
}

and I tested this works as I would expect.

So I don't see a need.

> src/java.desktop/macosx/native/libawt_lwawt/awt/CFileDialog.m line 213:
> 
>> 211: 
>> 212:     [ThreadUtilities performOnMainThreadWaiting:[NSThread isMainThread] 
>> block:^(){
>> 213:         if (dialogDelegate->inModalLoop == YES) {
> 
> To avoid possible dereferencing an object in case it has been freed, 
> shouldn't we retain the `dialogDelegate` before `performOnMainThreadWaiting`?

Not sure if that is possible, but a retain/release around this should be safe.

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

PR Review Comment: https://git.openjdk.org/jdk/pull/30715#discussion_r3150773613
PR Review Comment: https://git.openjdk.org/jdk/pull/30715#discussion_r3150505589

Reply via email to