mirror of
https://github.com/JetBrains/JetBrainsRuntime.git
synced 2025-12-06 09:29:38 +01:00
JBR-2562: fixed invokation of parent method
(cherry picked from commit93cbab2f2d) JBR-2562: suppress exceptions from [NSWindow _changeJustMain] temporary workaround to prevent crashes (cherry picked from commitdd055b5970) (cherry picked from commit55eba1d802)
This commit is contained in:
@@ -23,6 +23,7 @@
|
||||
* questions.
|
||||
*/
|
||||
|
||||
#include <objc/objc-runtime.h>
|
||||
#import <Cocoa/Cocoa.h>
|
||||
|
||||
#import "sun_lwawt_macosx_CPlatformWindow.h"
|
||||
@@ -34,6 +35,7 @@
|
||||
#import "AWTView.h"
|
||||
#import "GeomUtilities.h"
|
||||
#import "ThreadUtilities.h"
|
||||
#import "NSApplicationAWT.h"
|
||||
#import "JNIUtilities.h"
|
||||
|
||||
#define MASK(KEY) \
|
||||
@@ -123,6 +125,29 @@ static NSPoint lastTopLeftPoint;
|
||||
@implementation AWTWindow_Normal
|
||||
AWT_NS_WINDOW_IMPLEMENTATION
|
||||
|
||||
// suppress exception (actually assertion) from [NSWindow _changeJustMain]
|
||||
// workaround for https://youtrack.jetbrains.com/issue/JBR-2562
|
||||
- (void)_changeJustMain {
|
||||
@try {
|
||||
// NOTE: we can't use [super _changeJustMain] directly because of the warning ('may not perform to selector')
|
||||
// And [super performSelector:@selector(_changeJustMain)] will invoke this method (not a base method).
|
||||
// So do it with objc-runtime.h (see stackoverflow.com/questions/14635024/using-objc-msgsendsuper-to-invoke-a-class-method)
|
||||
Class superClass = [self superclass];
|
||||
struct objc_super mySuper = {
|
||||
self,
|
||||
class_isMetaClass(object_getClass(self)) //check if we are an instance or Class
|
||||
? object_getClass(superClass) //if we are a Class, we need to send our metaclass (our Class's Class)
|
||||
: superClass //if we are an instance, we need to send our Class (which we already have)
|
||||
};
|
||||
void (*_objc_msgSendSuper)(struct objc_super *, SEL) = (void *)&objc_msgSendSuper; //cast our pointer so the compiler can sort out the ABI
|
||||
(*_objc_msgSendSuper)(&mySuper, @selector(_changeJustMain));
|
||||
} @catch (NSException *ex) {
|
||||
NSLog(@"WARNING: suppressed exception from _changeJustMain (workaround for JBR-2562)");
|
||||
NSProcessInfo *processInfo = [NSProcessInfo processInfo];
|
||||
[NSApplicationAWT logException:ex forProcess:processInfo];
|
||||
}
|
||||
}
|
||||
|
||||
// Gesture support
|
||||
- (void)postGesture:(NSEvent *)event as:(jint)type a:(jdouble)a b:(jdouble)b {
|
||||
AWT_ASSERT_APPKIT_THREAD;
|
||||
|
||||
@@ -41,6 +41,7 @@ JNIEXPORT @interface NSApplicationAWT : NSApplication {
|
||||
- (void) waitForDummyEvent:(double) timeout;
|
||||
|
||||
+ (void) runAWTLoopWithApp:(NSApplication*)app;
|
||||
+ (void)logException:(NSException *)exception forProcess:(NSProcessInfo*)processInfo;
|
||||
|
||||
@end
|
||||
|
||||
|
||||
Reference in New Issue
Block a user