Home » Eclipse Projects » Eclipse Platform » Lock problem on Mac
Lock problem on Mac [message #334862] |
Wed, 04 March 2009 09:27 |
Richard Oliver Legendi![Friend of Eclipse Friend](/donate/web-api/friends_decorator.php?email=rlegendi%40aitia.ai) Messages: 34 Registered: July 2009 |
Member |
|
|
Hi all,
I'm trying to port our Eclipse product to Mac (Mac OS X Leopard, version 10.5.6,
default J2SE 5.0, 64-bit edition acquired from Apple Software Updates), but I
ran into some difficulties I cannot solve myself.
I'm only able to start debugging our product with an Europa, build version:
3.3.2, build id: M20080221-1800. I develop this product using Ganymede, but I
had to try ~5 different Eclipse versions/builds under Mac because of several
errors. I'm even unable to start debugging the full product, but starting a
simple Eclipse environment to test the plug-ins is managed to work (that's
enough for me yet).
The basic problem is that I'm trying to show a JFrame from a GUI thread, and I
have to wait for the closing of the frame (using a modal JDialog would be a
great solution, but I cannot do that, I don't have any influence on that part of
the code).
The sketch of the code structure I'm using is something like this:
// I need to be in a GUI thread because I have to display some stuff
// in the console.
Display.getDefault().syncExec( new Runnable() {
public void run() {
SomeClass.showFrame();
}
});
// in one of the jars included in the plugin dependencies
public class SomeClass {
// Just a synchronization object
final Object stop = new Object();
public static void showFrame() {
SwingUtilities.invokeLater(new Runnable() { // [1]
// SwingUtilities.invokeAndWait(new Runnable() { // [1b]
// java.awt.EventQueue.invokeLater(new Runnable() { // [2]
// Thread kicker = new Thread() { // [3]
public void run() {
// building the frame
...
frame.setVisible(true);
frame.addWindowListener(new WindowAdapter() {
public void windowClosing(WindowEvent e) {
synchronized (stop) { stop.notifyAll(); }
// doing some other stuff ...
}
});
}
// kicker.start();
synchronized (stop) {
try { // [4]
stop.wait();
} catch (InterruptedException e) {
return false;
}
// while (loop) { // [5]
// Thread.sleep(200);
// }
});
}
Bit messy but its legacy code I have to live with - albeit this construction
works well on both Linux and Windows (with the Sun JVM implementation), and I
cannot find out what causes the problem.
What I guess is that there's a mess with the SWT/Swing GUI threads but I cannot
figure out how to solve it. I guess there's a trivial solution but unfortunately
I'm not an expert of neither SWT nor Swing.
The exact problem I experience is that the program dumps error messages like this:
2009-02-27 11:48:02.421 java[281:80f] [Java CocoaComponent compatibility mode]:
Enabled
2009-02-27 11:48:02.423 java[281:80f] [Java CocoaComponent compatibility mode]:
Setting timeout for SWT to 0.100000
2009-02-27 11:48:44.876 java[281:54e03] *** -[NSConditionLock unlock]: lock
(<NSConditionLock: 0x2c8de8d0> '(null)') unlocked when not locked
2009-02-27 11:48:44.876 java[281:54e03] *** Break on _NSLockError() to debug.
2009-02-27 11:48:45.522 java[281:54e03] *** -[NSConditionLock unlock]: lock
(<NSConditionLock: 0x1e3470> '(null)') unlocked when not locked
.... (many lines just like the last ones)
and then simply 'hangs'. I've tried to locate the source of these exceptions but
it seems they all come from a Swing call (like pack(), etc.).
About the commented lines: I've played around with different approaches.
[1] has the same result as [1b], [2] and [3]. Even tried to replace [3] with [4]
to see if it gives me the possibility to interact but there was no change.
It seems to me the wait() is called on the Swing thread (?), but that's just a
suspicion. I've attached the existing threads under both win/mac in the start of
the showFrame() function.
I've found this post in the archives that has some relations to my problem I think:
http://dev.eclipse.org/newslists/news.eclipse.platform.swt/m sg43240.html
But it seems I'm doing exactly the same as Scott suggests here, and it doesn't
works :-(
I've also tried to call asyncExec() on Display instead of syncExec(), but that
was also fruitless, I got the exactly same results.
Haven't found any other valuable info on the net.
Any help/link/doc/suggestion/idea would be greatly appreciated.
Best regards,
---
Richard O. Legendi, programmer
AITIA International Inc.
E-mail: rlegendi@aitia.ai
------------------------------------------------------------ --------------
Threads under Macintosh:
org.eclipse.equinox.launcher.Main at localhost:49458
Thread [main] (Running)
Daemon Thread [Thread-0] (Suspended (breakpoint at line 236 in FOBWizard))
// here is the showFrame() function
RunnableLock.run() line: 35
UISynchronizer(Synchronizer).runAsyncMessages(boolean) line: 129
Display.runAsyncMessages(boolean) line: 3214
Display.readAndDispatch() line: 2954
Workbench.runEventLoop(Window$IExceptionHandler, Display) line: 2389
Workbench.runUI() line: 2353
Workbench.access$4(Workbench) line: 2219
Workbench$4.run() line: 466
Realm.runWithDefault(Realm, Runnable) line: 289
Workbench.createAndRunWorkbench(Display, WorkbenchAdvisor) line: 461
PlatformUI.createAndRunWorkbench(Display, WorkbenchAdvisor) line: 149
IDEApplication.start(IApplicationContext) line: 106
EclipseAppHandle.run(Object) line: 169
EclipseAppLauncher.runApplication(Object) line: 106
EclipseAppLauncher.start(Object) line: 76
EclipseStarter.run(Object) line: 363
EclipseStarter.run(String[], Runnable) line: 176
NativeMethodAccessorImpl.invoke0(Method, Object, Object[]) line: not
available [native method]
NativeMethodAccessorImpl.invoke(Object, Object[]) line: 39
DelegatingMethodAccessorImpl.invoke(Object, Object[]) line: 25
Method.invoke(Object, Object...) line: 585
Main.invokeFramework(String[], URL[]) line: 508
Main.basicRun(String[]) line: 447
Main.run(String[]) line: 1173
Main.main(String[]) line: 1148
Daemon Thread [State Data Manager] (Running)
Daemon Thread [Framework Event Dispatcher] (Running)
Daemon Thread [Start Level Event Dispatcher] (Running)
Thread [Worker-0] (Running)
Thread [Worker-1] (Running)
Daemon Thread [Java indexing] (Running)
Thread [Worker-2] (Running)
Thread [AWT-Shutdown] (Running)
Daemon Thread [org.eclipse.jface.text.reconciler.MonoReconciler] (Running)
Thread [Worker-3] (Running)
Thread [Worker-4] (Running)
Thread [Timer-0] (Running)
Thread [Timer-1] (Running)
Daemon Thread [Timer-2] (Running)
Daemon Thread [Thread-8] (Running)
Daemon Thread [Thread-9] (Running)
Thread [Worker-5] (Running)
Thread [AWT-EventQueue-0] (Running)
Thread [Laf-Widget fade tracker] (Running)
------------------------------------------------------------ --------------
Threads under Windows:
org.eclipse.equinox.launcher.Main at localhost:2174
Thread [main] (Suspended (entry into method loadWizard in FOBWizard))
// here is the showFrame() function
UISynchronizer(Synchronizer).syncExec(Runnable) line: 178
UISynchronizer.syncExec(Runnable) line: 150
Display.syncExec(Runnable) line: 4251
RunUtils.compile(CompilationOptions, String, boolean, boolean, String,
String) line: 336
RunUtils.compileAndGUIRun(CompilationOptions, String, String) line: 236
EditChartAction.performCompilation(CompilationOptions, String, String)
line: 37
EditChartAction(AFablesRunAction).run(IAction) line: 101
WWinPluginAction(PluginAction).runWithEvent(Event) line: 251
WWinPluginAction.runWithEvent(Event) line: 229
PluginActionCoolBarContributionItem(ActionContributionItem). handleWidgetSelection(Event,
boolean) line: 583
ActionContributionItem.access$2(ActionContributionItem, Event, boolean)
line: 500
ActionContributionItem$6.handleEvent(Event) line: 452
EventTable.sendEvent(Event) line: 84
ToolItem(Widget).sendEvent(Event) line: 1003
Display.runDeferredEvents() line: 3823
Display.readAndDispatch() line: 3422
Workbench.runEventLoop(Window$IExceptionHandler, Display) line: 2382
Workbench.runUI() line: 2346
Workbench.access$4(Workbench) line: 2198
Workbench$5.run() line: 493
Realm.runWithDefault(Realm, Runnable) line: 288
Workbench.createAndRunWorkbench(Display, WorkbenchAdvisor) line: 488
PlatformUI.createAndRunWorkbench(Display, WorkbenchAdvisor) line: 149
IDEApplication.start(IApplicationContext) line: 113
EclipseAppHandle.run(Object) line: 193
EclipseAppLauncher.runApplication(Object) line: 110
EclipseAppLauncher.start(Object) line: 79
EclipseStarter.run(Object) line: 382
EclipseStarter.run(String[], Runnable) line: 179
NativeMethodAccessorImpl.invoke0(Method, Object, Object[]) line: not
available [native method]
NativeMethodAccessorImpl.invoke(Object, Object[]) line: not available
DelegatingMethodAccessorImpl.invoke(Object, Object[]) line: not
available
Method.invoke(Object, Object...) line: not available
Main.invokeFramework(String[], URL[]) line: 549
Main.basicRun(String[]) line: 504
Main.run(String[]) line: 1236
Main.main(String[]) line: 1212
Daemon Thread [State Data Manager] (Running)
Daemon Thread [Framework Event Dispatcher] (Running)
Daemon Thread [Start Level Event Dispatcher] (Running)
Thread [Worker-0] (Running)
Daemon Thread [AWT-Windows] (Running)
Daemon Thread [Java indexing] (Running)
Thread [Worker-1] (Running)
Thread [Worker-2] (Running)
Thread [Worker-3] (Running)
Thread [Worker-4] (Running)
Thread [Worker-5] (Running)
Daemon Thread [org.eclipse.jface.text.reconciler.MonoReconciler] (Running)
Thread [AWT-Shutdown] (Running)
Thread [AWT-EventQueue-0] (Running)
Thread [Laf-Widget fade tracker] (Running)
|
|
|
Goto Forum:
Current Time: Sat Aug 17 01:41:25 GMT 2024
Powered by FUDForum. Page generated in 0.03865 seconds
|