Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.
Bug 63991 - hang in gtk_clipboard_wait_for_contents()
Summary: hang in gtk_clipboard_wait_for_contents()
Status: RESOLVED FIXED
Alias: None
Product: Platform
Classification: Eclipse Project
Component: SWT (show other bugs)
Version: 3.0   Edit
Hardware: PC Linux-GTK
: P1 critical (vote)
Target Milestone: 3.0 RC2   Edit
Assignee: Veronika Irvine CLA
QA Contact:
URL:
Whiteboard:
Keywords:
: 64184 64325 (view as bug list)
Depends on:
Blocks:
 
Reported: 2004-05-25 17:20 EDT by Billy Biggs CLA
Modified: 2004-06-07 11:10 EDT (History)
4 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Billy Biggs CLA 2004-05-25 17:20:16 EDT
I200405251200

Pasting a large file in eclipse results in a hang.  I reproduced the hang
copying ~ 170 lines from a text file into eclipse, pasting less than 100 lines
seems to work just fine.  Gtk+-2.4.


Thread [main] (Suspended)
	OS.gtk_clipboard_wait_for_contents(int, int) line: not available [native method]
	Clipboard.gtk_clipboard_wait_for_contents(int, int) line: 385
	Clipboard.getContents(Transfer) line: 191
	StyledText.paste() line: 5614
	SourceViewer(TextViewer).doOperation(int) line: 3387
	SourceViewer.doOperation(int) line: 744
	TextOperationAction$1.run() line: 122
	BusyIndicator.showWhile(Display, Runnable) line: 69
	TextOperationAction.run() line: 120
	TextOperationAction(Action).runWithEvent(Event) line: 881
	ActionHandler.execute(Map) line: 141
	Command.execute(Map) line: 132
	WorkbenchKeyboard.executeCommand(String) line: 469
	WorkbenchKeyboard.press(List, Event) line: 887
	WorkbenchKeyboard.processKeyEvent(List, Event) line: 928
	WorkbenchKeyboard.filterKeySequenceBindings(Event) line: 546
	WorkbenchKeyboard.access$2(WorkbenchKeyboard, Event) line: 494
	WorkbenchKeyboard$1.handleEvent(Event) line: 259
	EventTable.sendEvent(Event) line: 82
	Display.filterEvent(Event) line: 979
	StyledText(Widget).sendEvent(Event) line: 943
	StyledText(Widget).sendEvent(int, Event, boolean) line: 968
	StyledText(Widget).sendEvent(int, Event) line: 953
	StyledText(Control).sendKeyEvent(int, GdkEventKey) line: 2293
	StyledText(Control).gtk_key_press_event(int, int) line: 1793
	StyledText(Composite).gtk_key_press_event(int, int) line: 448
	StyledText(Widget).windowProc(int, int, int) line: 1194
	Display.windowProc(int, int, int) line: 3040
	OS.gtk_main_do_event(int) line: not available [native method]
	Display.eventProc(int, int) line: 839
	OS.gtk_main_iteration() line: not available [native method]
	Display.readAndDispatch() line: 2252
	Workbench.runEventLoop(Window$IExceptionHandler, Display) line: 1363
	Workbench.runUI() line: 1334
	Workbench.createAndRunWorkbench(Display, WorkbenchAdvisor) line: 253
	PlatformUI.createAndRunWorkbench(Display, WorkbenchAdvisor) line: 141
	IDEApplication.run(Object) line: 97
	PlatformActivator$1.run(Object) line: 307
	EclipseStarter.run(Object) line: 256
	EclipseStarter.run(String[], Runnable) line: 127
	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: 324
	Main.basicRun(String[]) line: 185
	Main.run(String[]) line: 638
	Main.main(String[]) line: 622
Comment 1 Veronika Irvine CLA 2004-05-26 14:50:28 EDT
*** Bug 64184 has been marked as a duplicate of this bug. ***
Comment 2 Veronika Irvine CLA 2004-06-02 14:50:00 EDT
Simple example showing bug:

Run the following two simple SWT examples.  They must be run as separate
applications to see the bug because clipboard data transfer within the same
application uses a different mechanism than data transfer between applications
(this is due to the GTK implementation on top of X).

Click on the "set clipboard" button then click on the "get clipboard" button. 
The "get clipboard" application will hang and get stuck in the dispatchEvents loop.

public static void main(String[] args) {
	Display display = new Display();
	final Clipboard clipboard = new Clipboard(display);
	Shell shell = new Shell(display);
	Button b = new Button(shell, SWT.PUSH);
	b.setText("set clipboard");
	b.pack();
	b.addListener(SWT.Selection, new Listener() {
		public void handleEvent(Event e) {
			char[] chars = new char[10000];
			for (int i = 0; i < chars.length - 1; i++) {
				if (i % 5 == 0) chars[i] = 'a';
				if (i % 5 == 1) chars[i] = 'b';
				if (i % 5 == 2) chars[i] = 'c';
				if (i % 5 == 3) chars[i] = 'd';
				if (i % 5 == 4) chars[i] = '\n';
			}
			chars[chars.length-1] = 'z';
			String longString = new String(chars);
			clipboard.setContents(new Object[] {longString}, new
Transfer[]{TextTransfer.getInstance()});
		}
	});
	shell.pack();
	shell.open();
	while (!shell.isDisposed()) {
		if (!display.readAndDispatch())
			display.sleep();
	}
	display.dispose();
}

public static void main(String[] args) {
	Display display = new Display();
	final Clipboard clipboard = new Clipboard(display);
	Shell shell = new Shell(display);
	Button b = new Button(shell, SWT.PUSH);
	b.setText("get clipboard");
	b.pack();
	b.addListener(SWT.Selection, new Listener() {
		public void handleEvent(Event e) {
			clipboard.getContents(TextTransfer.getInstance());
		}
	});
	shell.pack();
	shell.open();
	while (!shell.isDisposed()) {
		if (!display.readAndDispatch())
			display.sleep();
	}
	display.dispose();
}
Comment 3 Veronika Irvine CLA 2004-06-03 13:21:08 EDT
In addition to GDK_SELECTION_NOTIFY, the events GDK_PROPERTY_NOTIFY, 
GDK_SELECTION_CLEAR and GDK_SELECTION_REQUEST are allowed to be processed 
during gtk_clipboard_wait_for_contents.

Released into HEAD.
Comment 4 Veronika Irvine CLA 2004-06-07 11:10:52 EDT
*** Bug 64325 has been marked as a duplicate of this bug. ***