aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSilenio Quarti2013-07-29 10:21:06 (EDT)
committerSilenio Quarti2013-07-29 10:21:06 (EDT)
commitf507d7515e799b940aeca136e96156d689b4d11b (patch)
treea1d7c958b2ef0789f79d357a18f31bb4fde96f04
parent8066d1e12537b4895ad1a662279614b8007eb540 (diff)
downloadrt.equinox.framework-f507d7515e799b940aeca136e96156d689b4d11b.zip
rt.equinox.framework-f507d7515e799b940aeca136e96156d689b4d11b.tar.gz
rt.equinox.framework-f507d7515e799b940aeca136e96156d689b4d11b.tar.bz2
Bug 212617 - Launching Swing based IApplications on Mac still results in deadlock
-rw-r--r--bundles/org.eclipse.equinox.executable/library/carbon/eclipseCarbon.c101
-rw-r--r--bundles/org.eclipse.equinox.executable/library/make_version.mak2
2 files changed, 71 insertions, 32 deletions
diff --git a/bundles/org.eclipse.equinox.executable/library/carbon/eclipseCarbon.c b/bundles/org.eclipse.equinox.executable/library/carbon/eclipseCarbon.c
index 68ba067..0170578 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
diff --git a/bundles/org.eclipse.equinox.executable/library/make_version.mak b/bundles/org.eclipse.equinox.executable/library/make_version.mak
index 94682ca..39fb887 100644
--- a/bundles/org.eclipse.equinox.executable/library/make_version.mak
+++ b/bundles/org.eclipse.equinox.executable/library/make_version.mak
@@ -10,5 +10,5 @@
#*******************************************************************************
maj_ver=1
-min_ver=600
+min_ver=601
LIB_VERSION = $(maj_ver)$(min_ver)