Skip to main content
aboutsummaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorAlexandr Miloslavskiy2019-04-25 13:19:31 +0000
committerAlexandr Miloslavskiy2019-04-25 15:05:50 +0000
commit5e26c8581c55815ebb2334588f2cb9910a57b2ba (patch)
tree75f2c013c85e5149e889ab21f2704ff6841377ec /tests
parentd90c79a64b1cb6d43c3a9cdcfafd27589651d4f3 (diff)
downloadeclipse.platform.swt-5e26c8581c55815ebb2334588f2cb9910a57b2ba.tar.gz
eclipse.platform.swt-5e26c8581c55815ebb2334588f2cb9910a57b2ba.tar.xz
eclipse.platform.swt-5e26c8581c55815ebb2334588f2cb9910a57b2ba.zip
Bug 531634 - [GTK] Linux: Handle logoff / shutdown events from session manager
Hotfix for first version of the patch. Using System.exit() from Shell's 'SWT.Close' event caused deadlock, because main thread held 'Platform.lock' in its event loop and waited for shutdown hook, which waited for the lock - see also Bug 546743. Since multiple Displays are not possible currently (there's only dead code pretending to support it), it should be OK to have non-static object. Having it non-static removes the need for shutdown hook. Signed-off-by: Alexandr Miloslavskiy <alexandr.miloslavskiy@syntevo.com>
Diffstat (limited to 'tests')
-rw-r--r--tests/org.eclipse.swt.tests.gtk/ManualTests/org/eclipse/swt/tests/gtk/snippets/Bug531634_LogoffListener.java13
1 files changed, 12 insertions, 1 deletions
diff --git a/tests/org.eclipse.swt.tests.gtk/ManualTests/org/eclipse/swt/tests/gtk/snippets/Bug531634_LogoffListener.java b/tests/org.eclipse.swt.tests.gtk/ManualTests/org/eclipse/swt/tests/gtk/snippets/Bug531634_LogoffListener.java
index 8187df05c2..4e75c0a3be 100644
--- a/tests/org.eclipse.swt.tests.gtk/ManualTests/org/eclipse/swt/tests/gtk/snippets/Bug531634_LogoffListener.java
+++ b/tests/org.eclipse.swt.tests.gtk/ManualTests/org/eclipse/swt/tests/gtk/snippets/Bug531634_LogoffListener.java
@@ -19,6 +19,8 @@ import org.eclipse.swt.layout.FillLayout;
import org.eclipse.swt.widgets.*;
public class Bug531634_LogoffListener {
+ private static boolean isUserClosed = false;
+
public static void main (String [] args) {
Display display = new Display ();
@@ -34,7 +36,7 @@ public class Bug531634_LogoffListener {
});
display.addListener(SWT.Dispose, event -> {
- if (!shell.isDisposed()) {
+ if (!isUserClosed && !shell.isDisposed()) {
MessageBox dialog = new MessageBox(shell, SWT.ICON_INFORMATION);
dialog.setMessage("EndSession received.\nI will exit when you close this box. Time limit is 10 sec.");
dialog.open();
@@ -44,6 +46,15 @@ public class Bug531634_LogoffListener {
final Label label = new Label(shell, SWT.WRAP | SWT.CENTER);
label.setText("\n\n\nWhen you logoff/shutdown, I will give you messages on 'QueryEndSession' and 'EndSession'");
+ // The first version of the patch had deadlock when System.exit() was called in response to UI action.
+ // This happened because 'SWT.Close' is called from inside 'OS.g_main_context_iteration' and
+ // Platform.lock is held by main thread, locking all OS.xxx calls from other threads.
+ shell.addListener(SWT.Close, event -> {
+ isUserClosed = true;
+ display.dispose();
+ System.exit(0);
+ });
+
shell.open ();
while (!shell.isDisposed()) {

Back to the top