Bug 84870 - Hang in PasteBreakpointsAction.updateSelection
Summary: Hang in PasteBreakpointsAction.updateSelection
Status: VERIFIED FIXED
Alias: None
Product: Platform
Classification: Eclipse Project
Component: Debug (show other bugs)
Version: 3.1   Edit
Hardware: PC Linux-GTK
: P2 normal (vote)
Target Milestone: 3.1 M5   Edit
Assignee: Luc Bourlier CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2005-02-10 06:00 EST by Tom Hofmann CLA
Modified: 2005-02-16 10:45 EST (History)
2 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Tom Hofmann CLA 2005-02-10 06:00:47 EST
I20050209

The primary selection feature is neat, but it kills me when debugging: since my
debug target workbench always changes the selection when typing, I will run into
bug 44915 whenever I debug text editor stuff. Bug 44915 has not been a problem
any more until the primary selection feature was added, so I blame it on that...

Until I can disable that, I cannot debug any more - just had it four times in a row.

--

My stack dumps ususally look like:

"main" prio=1 tid=0x0805bcb0 nid=0x64d7 runnable [0xbfffc000..0xbfffd508]
	at org.eclipse.swt.internal.gtk.OS._gtk_clipboard_wait_for_contents(Native Method)
	at org.eclipse.swt.internal.gtk.OS.gtk_clipboard_wait_for_contents(OS.java:3361)
	at
org.eclipse.swt.dnd.Clipboard.gtk_clipboard_wait_for_contents(Clipboard.java:613)
	at org.eclipse.swt.dnd.Clipboard.getContents(Clipboard.java:289)
	at org.eclipse.swt.dnd.Clipboard.getContents(Clipboard.java:236)
	at
org.eclipse.debug.internal.ui.actions.breakpointGroups.PasteBreakpointsAction$1.run(PasteBreakpointsAction.java:101)
	at org.eclipse.swt.widgets.Synchronizer.syncExec(Synchronizer.java:147)
	at org.eclipse.ui.internal.UISynchronizer.syncExec(UISynchronizer.java:28)
	at org.eclipse.swt.widgets.Display.syncExec(Display.java:3189)
	at
org.eclipse.debug.internal.ui.actions.breakpointGroups.PasteBreakpointsAction.updateSelection(PasteBreakpointsAction.java:97)
[...]
Comment 1 Billy Biggs CLA 2005-02-10 10:00:36 EST
You say that the target workbench always changes the selection when typing: what
do you mean by that?  The PRIMARY clipboard won't be updated by Eclipse unless
you highlight some text with the mouse.

Also, I am confused a bit by your stack trace.  Are you trying to paste
something, or is the paste breakpoint action checking the clipboard too often
(similar to bug 78450)?
Comment 2 Tom Hofmann CLA 2005-02-10 11:42:33 EST
I guess I should not be making assumptions about why this is happening, I really
don't know whether it is the primary selection feature or something else.

It is always the breakpoint action updater that hangs, though. And I only saw it
when I triggered the breakpoint upon a keypress, that's why I figured it would
have to do with the selection. Thinking of it, it always happened when pressing
return in the editor, which causes a call to StyledText.setSelectedRange
internally (because of the auto-indenter).
Comment 3 Billy Biggs CLA 2005-02-10 11:48:57 EST
AFAICT, StyledText.setSelectionRange does not set the clipboard contents.  You
have to actually select text with your mouse to have the clipboard get set.

Regardless, if the breakpoint action is checking clipboard contents without you
explicitly hitting paste, I think this is a bug in the breakpoint action.
Comment 4 Tom Hofmann CLA 2005-02-10 13:34:58 EST
ok, let's bug debug a little... 

Moving to debug for commenting on the breakpoint action update.
Comment 5 Darin Wright CLA 2005-02-10 14:47:03 EST
Fixed in PasteBreakpointsAction and BreakpointsView. The action only updates 
when the selection changes and the view has focus, or when the view regains 
focus.
Comment 6 Darin Wright CLA 2005-02-10 14:47:23 EST
Changes to PasteBreakpointsAction and BreakpointsView.
Comment 7 Billy Biggs CLA 2005-02-10 14:53:20 EST
Why can it not only update when the user hits paste (or, why does it need to
update its state at all)?
Comment 8 Darin Swanson CLA 2005-02-14 16:23:46 EST
Adding DW for last comment
Comment 9 Darin Wright CLA 2005-02-14 16:29:21 EST
We update the state so that the action has proper enablement in the context 
menu, when the menu is realized. Otherwise the action will always be enabled 
and may/may not have an effect.
Comment 10 Billy Biggs CLA 2005-02-15 10:28:39 EST
I'm going to re-open this then.  It is still too easy to hang on Linux.  Here
are the steps I used with I20050215-0800.

  1. With the following application, put a breakpoint on the line
     with the call to shell.open().
  2. Debug.  Eclipse stops at the breakpoint.
  3. Click on the tab for the breakpoints view.
  4. Eclipse will now hang.

It would be better to have Paste always enabled in the menu than to hang waiting
for the application which owns the clipboard to respond.

public static void main(String [] args) {
    Display display = new Display();
    Shell shell = new Shell(display);
    Text text = new Text(shell, SWT.BORDER);
    text.setText("Please copy this text");
    text.setSelection(0, 10);
    text.copy();
    shell.open();
    while(!shell.isDisposed()) {
        if(!display.readAndDispatch()) display.sleep();
    }
    display.dispose();
}
Comment 11 Darin Wright CLA 2005-02-15 10:38:53 EST
OK, will fix for M5. It's unfortunate, but the paste action will always have 
to be enabled.
Comment 12 Darin Wright CLA 2005-02-15 11:50:34 EST
released to noon build.
Comment 13 Darin Wright CLA 2005-02-15 11:50:46 EST
please verify, Luc.
Comment 14 Billy Biggs CLA 2005-02-15 12:17:44 EST
If bug 39369 is fixed, we may have a way to solve problems like this in a more
sane way.
Comment 15 Luc Bourlier CLA 2005-02-15 20:38:34 EST
Verified.
Comment 16 Darin Swanson CLA 2005-02-16 10:45:24 EST
I removed the unnecessary Clipboard passing to the constructor of the action 
(and the unread private field it was stored in).
Changes to BreakpointsView and PasteBreakpointsAction