Skip to content

Commit 85a68d4

Browse files
committed
Revert "JBR-8651 Pycharm Crashing after lock/sleep: SIGABRT at # C [libsystem_kernel.dylib+0x9388] __pthread_kill / __displaycb_handle_block_invoke"
This reverts commit 986d578.
1 parent 3563344 commit 85a68d4

20 files changed

Lines changed: 313 additions & 785 deletions

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

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -741,7 +741,8 @@ - (jobject)awtComponent:(JNIEnv*)env
741741
DECLARE_CLASS_RETURN(jc_CPlatformView, "sun/lwawt/macosx/CPlatformView", NULL);
742742
DECLARE_FIELD_RETURN(jf_Peer, jc_CPlatformView, "peer", "Lsun/lwawt/LWWindowPeer;", NULL);
743743
if ((env == NULL) || (m_cPlatformView == NULL)) {
744-
NSAPP_AWT_LOG_MESSAGE(@"Apple AWT: Error AWTView:awtComponent given bad parameters.");
744+
NSLog(@"Apple AWT : Error AWTView:awtComponent given bad parameters.");
745+
NSLog(@"%@",[NSThread callStackSymbols]);
745746
return NULL;
746747
}
747748

@@ -754,7 +755,8 @@ - (jobject)awtComponent:(JNIEnv*)env
754755
DECLARE_CLASS_RETURN(jc_LWWindowPeer, "sun/lwawt/LWWindowPeer", NULL);
755756
DECLARE_FIELD_RETURN(jf_Target, jc_LWWindowPeer, "target", "Ljava/awt/Component;", NULL);
756757
if (peer == NULL) {
757-
NSAPP_AWT_LOG_MESSAGE(@"Apple AWT: Error AWTView:awtComponent got null peer from CPlatformView");
758+
NSLog(@"Apple AWT : Error AWTView:awtComponent got null peer from CPlatformView");
759+
NSLog(@"%@",[NSThread callStackSymbols]);
758760
return NULL;
759761
}
760762
jobject comp = (*env)->GetObjectField(env, peer, jf_Target);

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

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -232,9 +232,10 @@ - (void)_changeJustMain {
232232
};
233233
void (*_objc_msgSendSuper)(struct objc_super *, SEL) = (void *)&objc_msgSendSuper; //cast our pointer so the compiler can sort out the ABI
234234
(*_objc_msgSendSuper)(&mySuper, @selector(_changeJustMain));
235-
} @catch (NSException *exception) {
235+
} @catch (NSException *ex) {
236236
NSLog(@"WARNING: suppressed exception from _changeJustMain (workaround for JBR-2562)");
237-
NSAPP_AWT_LOG_EXCEPTION(exception);
237+
NSProcessInfo *processInfo = [NSProcessInfo processInfo];
238+
[NSApplicationAWT logException:ex forProcess:processInfo];
238239
}
239240
}
240241

@@ -1058,9 +1059,10 @@ - (void) _deliverMoveResizeEvent {
10581059
NSRect frame;
10591060
@try {
10601061
frame = ConvertNSScreenRect(env, [self.nsWindow frame]);
1061-
} @catch (NSException *exception) {
1062+
} @catch (NSException *e) {
10621063
NSLog(@"WARNING: suppressed exception from ConvertNSScreenRect() in [AWTWindow _deliverMoveResizeEvent]");
1063-
NSAPP_AWT_LOG_EXCEPTION(exception);
1064+
NSProcessInfo *processInfo = [NSProcessInfo processInfo];
1065+
[NSApplicationAWT logException:e forProcess:processInfo];
10641066
return;
10651067
}
10661068

@@ -1394,9 +1396,7 @@ - (CGFloat) customTitleBarHeight {
13941396
jobject target = (*env)->GetObjectField(env, platformWindow, jf_target);
13951397
if (target) {
13961398
h = (CGFloat) (*env)->CallFloatMethod(env, target, jm_internalCustomTitleBarHeight);
1397-
if ((*env)->ExceptionCheck(env)) {
1398-
(*env)->ExceptionDescribe(env);
1399-
} else {
1399+
if (!(*env)->ExceptionCheck(env)) {
14001400
self.customTitleBarControlsVisible = (BOOL) (*env)->CallBooleanMethod(env, target, jm_internalCustomTitleBarControlsVisible);
14011401
}
14021402
(*env)->DeleteLocalRef(env, target);
@@ -1565,8 +1565,8 @@ - (void)sendEvent:(NSEvent *)event {
15651565
GET_CPLATFORM_WINDOW_CLASS();
15661566
DECLARE_METHOD(jm_deliverNCMouseDown, jc_CPlatformWindow, "deliverNCMouseDown", "()V");
15671567
(*env)->CallVoidMethod(env, platformWindow, jm_deliverNCMouseDown);
1568-
(*env)->DeleteLocalRef(env, platformWindow);
15691568
CHECK_EXCEPTION();
1569+
(*env)->DeleteLocalRef(env, platformWindow);
15701570
}
15711571
}
15721572
}
@@ -2234,7 +2234,6 @@ - (void)drawButton: (int)index {
22342234
DECLARE_METHOD_RETURN(jm_isIgnoreMouseEvents, jc_Window, "isIgnoreMouseEvents", "()Z", 0);
22352235
isIgnoreMouseEvents = (*env)->CallBooleanMethod(env, awtWindow, jm_isIgnoreMouseEvents) == JNI_TRUE ? YES : NO;
22362236
(*env)->DeleteLocalRef(env, awtWindow);
2237-
CHECK_EXCEPTION();
22382237
}
22392238
[ThreadUtilities performOnMainThreadWaiting:YES block:^(){
22402239

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -126,7 +126,7 @@ + (ApplicationDelegate *)sharedDelegate {
126126
BOOL isApplicationOwner = NO;
127127
if (NSApp != nil) {
128128
if ([NSApp isMemberOfClass:[NSApplication class]] && overrideDelegate) shouldInstall = YES;
129-
if ([NSApplicationAWT isNSApplicationAWT]) {
129+
if ([NSApp isKindOfClass:[NSApplicationAWT class]]) {
130130
shouldInstall = YES;
131131
isApplicationOwner = YES;
132132
}
@@ -213,7 +213,7 @@ - (id) init {
213213

214214
// Prep for about and preferences menu
215215
BOOL usingDefaultNib = YES;
216-
if ([NSApplicationAWT isNSApplicationAWT]) {
216+
if ([NSApp isKindOfClass:[NSApplicationAWT class]]) {
217217
usingDefaultNib = [NSApp usingDefaultNib];
218218
}
219219
if (!usingDefaultNib) return self;

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

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,6 @@ static void TransferFailed(JNIEnv *env, jobject jthis, jlong jdroptarget, jlong
102102
// Pass the data to drop target:
103103
@try {
104104
(*env)->CallVoidMethod(env, jthis, newDataMethod, jformat, jdropdata); // AWT_THREADING Safe (!appKit)
105-
CHECK_EXCEPTION();
106105
} @catch (NSException *ex) {
107106
DLog2(@"[CDropTargetContextPeer startTransfer]: exception in newData() for %d.\n", (NSInteger) jdroptarget);
108107
(*env)->DeleteGlobalRef(env, jdropdata);

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

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -116,7 +116,6 @@
116116
(CGDirectDisplayID displayId, CGDisplayChangeSummaryFlags flags, void *userInfo)
117117
{
118118
AWT_ASSERT_APPKIT_THREAD;
119-
JNIEnv *env = [ThreadUtilities getJNIEnv];
120119
JNI_COCOA_ENTER(env);
121120

122121
if (TRACE_DISPLAY_CALLBACKS) {
@@ -153,6 +152,7 @@
153152
block:^()
154153
{
155154
@try {
155+
JNIEnv *env = [ThreadUtilities getJNIEnv];
156156
jobject graphicsEnv = (*env)->NewLocalRef(env, cgeRef);
157157
if (graphicsEnv == NULL) return; // ref already GC'd
158158
DECLARE_CLASS(jc_CGraphicsEnvironment, "sun/awt/CGraphicsEnvironment");
@@ -173,6 +173,7 @@
173173

174174
// braces to reduce variable scope
175175
{
176+
JNIEnv *env = [ThreadUtilities getJNIEnv];
176177
jobject graphicsEnv = (*env)->NewLocalRef(env, cgeRef);
177178
if (graphicsEnv == NULL) return; // ref already GC'd
178179
DECLARE_CLASS(jc_CGraphicsEnvironment, "sun/awt/CGraphicsEnvironment");

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

Lines changed: 34 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -223,12 +223,6 @@ void JavaCT_BreakupUnicodeIntoSurrogatePairs(int uniChar, UTF16Char charRef[]) {
223223
// Using the Quartz Surface Data context, draw a hot-substituted character run
224224
void JavaCT_DrawTextUsingQSD(JNIEnv *env, const QuartzSDOps *qsdo, const AWTStrike *strike, const jchar *chars, const jsize length)
225225
{
226-
NSAttributedString *attribString = nil;
227-
CTTypesetterRef typeSetterRef = NULL;
228-
CTLineRef lineRef = NULL;
229-
230-
JNI_COCOA_ENTER(env);
231-
232226
CGContextRef cgRef = qsdo->cgRef;
233227

234228
AWTFont *awtFont = strike->fAWTFont;
@@ -257,18 +251,20 @@ render using the right font (see bug 7183516) when attribString is not
257251
258252
CTTypesetterRef typeSetterRef = CTTypesetterCreateWithAttributedStringAndOptions((CFAttributedStringRef) attribString, (CFDictionaryRef) ctsDictionaryFor(nsFont, JRSFontStyleUsesFractionalMetrics(strike->fStyle)));
259253
*/
260-
attribString = [[NSAttributedString alloc]
254+
NSAttributedString *attribString = [[NSAttributedString alloc]
261255
initWithString:string
262256
attributes:ctsDictionaryFor(nsFont, JRSFontStyleUsesFractionalMetrics(strike->fStyle))];
263257

264-
typeSetterRef = CTTypesetterCreateWithAttributedString((CFAttributedStringRef) attribString);
258+
CTTypesetterRef typeSetterRef = CTTypesetterCreateWithAttributedString((CFAttributedStringRef) attribString);
265259

266260
CFRange range = {0, length};
267-
lineRef = CTTypesetterCreateLine(typeSetterRef, range);
261+
CTLineRef lineRef = CTTypesetterCreateLine(typeSetterRef, range);
268262

269263
CTLineDraw(lineRef, cgRef);
270264

271-
JNI_COCOA_EXIT_WITH_ACTION(env, ( [attribString release], CFRelease_even_NULL(lineRef), CFRelease_even_NULL(typeSetterRef) ) );
265+
[attribString release];
266+
CFRelease(lineRef);
267+
CFRelease(typeSetterRef);
272268
}
273269

274270

@@ -284,16 +280,16 @@ render using the right font (see bug 7183516) when attribString is not
284280
return;
285281
}
286282

287-
JNI_COCOA_ENTER(env);
288-
289283
qsdo->BeginSurface(env, qsdo, SD_Text);
290284
if (qsdo->cgRef == NULL)
291285
{
286+
qsdo->FinishSurface(env, qsdo);
292287
return;
293288
}
294289

295290
CGContextRef cgRef = qsdo->cgRef;
296291

292+
297293
CGContextSaveGState(cgRef);
298294
JRSFontSetRenderingStyleOnContext(cgRef, strike->fStyle);
299295

@@ -307,7 +303,7 @@ render using the right font (see bug 7183516) when attribString is not
307303

308304
CGContextRestoreGState(cgRef);
309305

310-
JNI_COCOA_RENDERER_EXIT(env);
306+
qsdo->FinishSurface(env, qsdo);
311307
}
312308

313309
#pragma mark --- Glyph Vector Pipeline ---
@@ -532,34 +528,40 @@ render using the right font (see bug 7183516) when attribString is not
532528
CGSize advances[length];
533529
doDrawGlyphsPipe_fillGlyphAndAdvanceBuffers(env, qsdo, strike, gVector, glyphs, uniChars, advances, length, glyphsArray);
534530
}
535-
else {
536-
CGGlyph *glyphs = NULL;
537-
int *uniChars = NULL;
538-
CGSize *advances = NULL;
539-
@try {
540-
// otherwise, we should malloc and free buffers for this large run
541-
glyphs = (CGGlyph *)malloc(sizeof(CGGlyph) * length);
542-
uniChars = (int *) malloc(sizeof(int) * length);
543-
advances = (CGSize *) malloc(sizeof(CGSize) * length);
531+
else
532+
{
533+
// otherwise, we should malloc and free buffers for this large run
534+
CGGlyph *glyphs = (CGGlyph *)malloc(sizeof(CGGlyph) * length);
535+
int *uniChars = (int *)malloc(sizeof(int) * length);
536+
CGSize *advances = (CGSize *)malloc(sizeof(CGSize) * length);
544537

545-
if ((glyphs == NULL) || (uniChars == NULL) || (advances == NULL)) {
546-
[NSException raise:NSMallocException format:@"allocation failure (%s:%d %s)", __FILE__, __LINE__, __FUNCTION__];
547-
} else {
548-
doDrawGlyphsPipe_fillGlyphAndAdvanceBuffers(env, qsdo, strike, gVector, glyphs, uniChars, advances, length, glyphsArray);
549-
}
550-
} @finally {
551-
if (glyphs != NULL) {
538+
if (glyphs == NULL || uniChars == NULL || advances == NULL)
539+
{
540+
(*env)->DeleteLocalRef(env, glyphsArray);
541+
[NSException raise:NSMallocException format:@"%s-%s:%d", __FILE__, __FUNCTION__, __LINE__];
542+
if (glyphs)
543+
{
552544
free(glyphs);
553545
}
554-
if (uniChars != NULL) {
546+
if (uniChars)
547+
{
555548
free(uniChars);
556549
}
557-
if (advances != NULL) {
550+
if (advances)
551+
{
558552
free(advances);
559553
}
560-
(*env)->DeleteLocalRef(env, glyphsArray);
554+
return;
561555
}
556+
557+
doDrawGlyphsPipe_fillGlyphAndAdvanceBuffers(env, qsdo, strike, gVector, glyphs, uniChars, advances, length, glyphsArray);
558+
559+
free(glyphs);
560+
free(uniChars);
561+
free(advances);
562562
}
563+
564+
(*env)->DeleteLocalRef(env, glyphsArray);
563565
}
564566

565567
// Setup and save the state of the CGContext, and apply any java.awt.Font transforms to the context.

0 commit comments

Comments
 (0)