Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSilenio Quarti2013-07-29 14:21:06 +0000
committerSilenio Quarti2013-07-29 14:21:06 +0000
commitf507d7515e799b940aeca136e96156d689b4d11b (patch)
treea1d7c958b2ef0789f79d357a18f31bb4fde96f04 /bundles/org.eclipse.equinox.executable/library/carbon/eclipseCarbon.c
parent8066d1e12537b4895ad1a662279614b8007eb540 (diff)
downloadrt.equinox.framework-f507d7515e799b940aeca136e96156d689b4d11b.tar.gz
rt.equinox.framework-f507d7515e799b940aeca136e96156d689b4d11b.tar.xz
rt.equinox.framework-f507d7515e799b940aeca136e96156d689b4d11b.zip
Bug 212617 - Launching Swing based IApplications on Mac still results in deadlock
Diffstat (limited to 'bundles/org.eclipse.equinox.executable/library/carbon/eclipseCarbon.c')
-rw-r--r--bundles/org.eclipse.equinox.executable/library/carbon/eclipseCarbon.c101
1 files changed, 70 insertions, 31 deletions
diff --git a/bundles/org.eclipse.equinox.executable/library/carbon/eclipseCarbon.c b/bundles/org.eclipse.equinox.executable/library/carbon/eclipseCarbon.c
index 68ba06770..0170578b3 100644
--- a/bundles/org.eclipse.equinox.executable/library/carbon/eclipseCarbon.c
+++ b/bundles/org.eclipse.equinox.executable/library/carbon/eclipseCarbon.c
@@ -101,6 +101,59 @@ static NSWindow* window = nil;
window = nil;
}
++ (int)show: (NSString *) featureImage {
+ ProcessSerialNumber psn;
+ if (GetCurrentProcess(&psn) == noErr) {
+ TransformProcessType(&psn, kProcessTransformToForegroundApplication);
+ SetFrontProcess(&psn);
+ }
+ if (window != NULL)
+ return 0; /*already showing */
+ if (featureImage == NULL)
+ return ENOENT;
+
+ int result = ENOENT;
+ NSAutoreleasePool* pool = [[NSAutoreleasePool alloc] init];
+ [NSApplication sharedApplication];
+ NSImage* image = [[NSImage alloc] initByReferencingFile: featureImage];
+ [featureImage release];
+ if (image != NULL) {
+ NSImageRep* imageRep = [image bestRepresentationForDevice: [[NSScreen mainScreen] deviceDescription]];
+ NSRect rect = {{0, 0}, {[imageRep pixelsWide], [imageRep pixelsHigh]}};
+ [image setSize: NSMakeSize([imageRep pixelsWide], [imageRep pixelsHigh])];
+ [image autorelease];
+ window = [[KeyWindow alloc] initWithContentRect: rect styleMask: NSBorderlessWindowMask backing: NSBackingStoreBuffered defer: 0];
+ if (window != nil) {
+ [window center];
+ [window setBackgroundColor: [NSColor colorWithPatternImage: image]];
+ [window makeKeyAndOrderFront: nil];
+ dispatchMessages();
+ result = 0;
+ }
+ }
+ [pool release];
+ return result;
+}
+
++ (void)shutdown {
+ if (window != 0) {
+ NSAutoreleasePool* pool = [[NSAutoreleasePool alloc] init];
+ [window close];
+ window = nil;
+ [pool release];
+ }
+}
+
++ (void)dispatch {
+ NSAutoreleasePool* pool = [[NSAutoreleasePool alloc] init];
+ NSEvent* event;
+ NSApplication* application = [NSApplication sharedApplication];
+ while ((event = [application nextEventMatchingMask: 0 untilDate: nil inMode: NSDefaultRunLoopMode dequeue: TRUE]) != nil) {
+ [application sendEvent: event];
+ }
+ [pool release];
+}
+
@end
@interface AppleEventDelegate : NSObject
@@ -185,50 +238,36 @@ int reuseWorkbench(_TCHAR** filePath, int timeout) {
*/
int showSplash( const _TCHAR* featureImage )
{
- if (window != NULL)
- return 0; /*already showing */
- if (featureImage == NULL)
- return ENOENT;
-
- int result = ENOENT;
+ int result = 0;
NSAutoreleasePool* pool = [[NSAutoreleasePool alloc] init];
- [NSApplication sharedApplication];
- NSImage* image = [[NSImage alloc] initByReferencingFile: [NSString stringWithUTF8String: featureImage]];
- if (image != NULL) {
- NSImageRep* imageRep = [image bestRepresentationForDevice: [[NSScreen mainScreen] deviceDescription]];
- NSRect rect = {{0, 0}, {[imageRep pixelsWide], [imageRep pixelsHigh]}};
- [image setSize: NSMakeSize([imageRep pixelsWide], [imageRep pixelsHigh])];
- [image autorelease];
- window = [[KeyWindow alloc] initWithContentRect: rect styleMask: NSBorderlessWindowMask backing: NSBackingStoreBuffered defer: 0];
- if (window != nil) {
- [window center];
- [window setBackgroundColor: [NSColor colorWithPatternImage: image]];
- [window makeKeyAndOrderFront: nil];
- dispatchMessages();
- result = 0;
- }
+ NSString *str = [[NSString stringWithUTF8String: featureImage] retain];
+ if ([NSThread isMainThread]) {
+ result = [KeyWindow show: str];
+ } else {
+ [KeyWindow performSelectorOnMainThread: @selector(show:) withObject: str waitUntilDone: 0];
}
[pool release];
return result;
}
void takeDownSplash() {
- if (window != 0) {
- NSAutoreleasePool* pool = [[NSAutoreleasePool alloc] init];
- [window close];
- window = nil;
- [pool release];
+ NSAutoreleasePool* pool = [[NSAutoreleasePool alloc] init];
+ if ([NSThread isMainThread]) {
+ [KeyWindow shutdown];
+ } else {
+ [KeyWindow performSelectorOnMainThread: @selector(shutdown) withObject: nil waitUntilDone: 0];
}
+ [pool release];
}
void dispatchMessages() {
NSAutoreleasePool* pool = [[NSAutoreleasePool alloc] init];
- NSEvent* event;
- NSApplication* application = [NSApplication sharedApplication];
- while ((event = [application nextEventMatchingMask: 0 untilDate: nil inMode: NSDefaultRunLoopMode dequeue: TRUE]) != nil) {
- [application sendEvent: event];
+ if ([NSThread isMainThread]) {
+ [KeyWindow dispatch];
+ } else {
+ [KeyWindow performSelectorOnMainThread: @selector(dispatch) withObject: nil waitUntilDone: 0];
}
- [pool release];
+ [pool release];
}
#else

Back to the top