Bug 296212 - [terminal] Fail to paste text into terminal control on some Linux hosts
Summary: [terminal] Fail to paste text into terminal control on some Linux hosts
Status: RESOLVED FIXED
Alias: None
Product: Target Management
Classification: Tools
Component: Terminal (show other bugs)
Version: 3.2   Edit
Hardware: PC Linux-GTK
: P3 normal (vote)
Target Milestone: 3.2 M6   Edit
Assignee: Uwe Stieber CLA
QA Contact: Martin Oberhuber CLA
URL:
Whiteboard:
Keywords:
Depends on: 294719
Blocks: 166150 304061
  Show dependency tree
 
Reported: 2009-11-26 04:56 EST by Uwe Stieber CLA
Modified: 2010-02-28 17:50 EST (History)
1 user (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Uwe Stieber CLA 2009-11-26 04:56:06 EST
CQ: WIND00192293

On some Linux systems it can be observed that pasting a text into the terminal control does not work. Sometimes the text can be pasted to an external editor, sometimes not.

While debugging the issue on a system where it can be reproduced, it turned out that the "hide menu" event is executed before the action got the chance to perform it's execution logic. run() is therefor never called as the action got disabled already.

In this context, the use of the "aboutToShow" parameter to the updateAction(...) method should be reviewed for each terminal action.
Comment 1 Martin Oberhuber CLA 2009-11-26 05:07:23 EST
This is a regression introduced by the fix for bug 294719, which added an "aboutToShow" check for computing enabled state. Since that fix was introduced after 3.1.1, only 3.2 is affected for now. Correct code should look like this:

public void updateAction(boolean aboutToShow) {
    if(aboutToShow) {
        ITerminalViewControl target = getTarget();
        boolean bEnabled = target != null && target.getClipboard() != null
              && !target.getClipboard().isDisposed();
        if (bEnabled) {
            String strText = (String) target.getClipboard().getContents(
                TextTransfer.getInstance());
           bEnabled = ((strText != null) && (!strText.equals("")) 
               && (target.getState() == TerminalState.CONNECTED));//$NON-NLS-1$
        }
        setEnabled(bEnabled);
    }
}

That is, we only re-compute and re-set enabled state when the menu is about to show. Otherwise, enabled state remains as it was before.

Note that respecting "aboutToShow" is only a Performance improvement and could also be omitted completely. In fact omitting it may be necessary to properly handle the retargetable global cut/copy/paste actions eventually as per bug 166150.

The same arguments apply to both TerminalActionPaste and TerminalActionCopy.
Comment 2 Martin Oberhuber CLA 2009-11-26 05:20:14 EST
CQ:WIND00192293
Comment 3 Martin Oberhuber CLA 2010-02-28 17:50:59 EST
Committed to the 3.2 Stream without the "aboutToShow" performance improvement.