< prev index next >

src/java.desktop/macosx/native/libawt_lwawt/awt/LWCToolkit.m

Print this page
rev 58521 : 7185258: [macosx] Deadlock in SunToolKit.realSync()
Reviewed-by: XXX

*** 1,7 **** /* ! * Copyright (c) 2011, 2019, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. Oracle designates this --- 1,7 ---- /* ! * Copyright (c) 2011, 2020, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. Oracle designates this
*** 68,84 **** --- 68,101 ---- static pthread_cond_t sAppKitStarted_cv = PTHREAD_COND_INITIALIZER; @implementation AWTToolkit static long eventCount; + static BOOL inDoDragDropLoop; + + + (BOOL) inDoDragDropLoop { + @synchronized(self) { + return inDoDragDropLoop; + } + } + + + (void) setInDoDragDropLoop:(BOOL)val { + @synchronized(self) { + inDoDragDropLoop = val; + } + } + (long) getEventCount{ + @synchronized(self) { return eventCount; + } } + (void) eventCountPlusPlus{ + @synchronized(self) { eventCount++; + } } + (jint) scrollStateWithEvent: (NSEvent*) event { if ([event type] != NSScrollWheel) {
*** 418,431 **** --- 435,454 ---- // - CGEventPost(), see CRobot.m // It was found that if we post an event via CGEventPost in robot and // immediately after this we will post the second event via // [NSApp postEvent] then sometimes the second event will be handled // first. The opposite isn't proved, but we use both here to be safer. + + // If the native drag is in progress, skip native sync. + if (!AWTToolkit.inDoDragDropLoop) { [theApp postDummyEvent:false]; [theApp waitForDummyEvent:timeout / 2.0]; + } + if (!AWTToolkit.inDoDragDropLoop) { [theApp postDummyEvent:true]; [theApp waitForDummyEvent:timeout / 2.0]; + } } else { // could happen if we are embedded inside SWT application, // in this case just spin a single empty block through // the event loop to give it a chance to process pending events
< prev index next >