From 0f9ca60727eb294be0828ecc1ba4340a4db45901 Mon Sep 17 00:00:00 2001 From: Michael Scharf Date: Tue, 9 Oct 2007 01:12:11 +0000 Subject: [PATCH] bug 205772: [terminal] crash on linux (division by zero) https://bugs.eclipse.org/bugs/show_bug.cgi?id=205772 --- .../terminal/test/ui/TerminalTextUITest.java | 3 +-- .../terminal/emulator/VT100TerminalControl.java | 4 ++-- .../tm/internal/terminal/textcanvas/TextCanvas.java | 12 +++++------- .../terminal/textcanvas/TextLineRenderer.java | 4 +--- 4 files changed, 9 insertions(+), 14 deletions(-) diff --git a/terminal/org.eclipse.tm.terminal.test/src/org/eclipse/tm/internal/terminal/test/ui/TerminalTextUITest.java b/terminal/org.eclipse.tm.terminal.test/src/org/eclipse/tm/internal/terminal/test/ui/TerminalTextUITest.java index 84ce334b59e..7d9bdf91a1a 100644 --- a/terminal/org.eclipse.tm.terminal.test/src/org/eclipse/tm/internal/terminal/test/ui/TerminalTextUITest.java +++ b/terminal/org.eclipse.tm.terminal.test/src/org/eclipse/tm/internal/terminal/test/ui/TerminalTextUITest.java @@ -82,8 +82,7 @@ public class TerminalTextUITest { // TODO how to get the initial size correctly! snapshot.updateSnapshot(false); fgModel=new PollingTextCanvasModel(snapshot); - fgTextCanvas=new TextCanvas(shell,fgModel, SWT.NONE); - fgTextCanvas.setCellRenderer(new TextLineRenderer(fgTextCanvas,fgModel)); + fgTextCanvas=new TextCanvas(shell,fgModel, SWT.NONE,new TextLineRenderer(fgTextCanvas,fgModel)); fgTextCanvas.setLayoutData(new GridData(GridData.FILL_BOTH)); diff --git a/terminal/org.eclipse.tm.terminal/src/org/eclipse/tm/internal/terminal/emulator/VT100TerminalControl.java b/terminal/org.eclipse.tm.terminal/src/org/eclipse/tm/internal/terminal/emulator/VT100TerminalControl.java index baf48386efb..efbcb76d795 100644 --- a/terminal/org.eclipse.tm.terminal/src/org/eclipse/tm/internal/terminal/emulator/VT100TerminalControl.java +++ b/terminal/org.eclipse.tm.terminal/src/org/eclipse/tm/internal/terminal/emulator/VT100TerminalControl.java @@ -486,8 +486,8 @@ public class VT100TerminalControl implements ITerminalControlForText, ITerminalC // TODO how to get the initial size correctly! snapshot.updateSnapshot(false); ITextCanvasModel canvasModel=new PollingTextCanvasModel(snapshot); - fCtlText=new TextCanvas(fWndParent,canvasModel,SWT.NONE); - fCtlText.setCellRenderer(new TextLineRenderer(fCtlText,canvasModel)); + fCtlText=new TextCanvas(fWndParent,canvasModel,SWT.NONE,new TextLineRenderer(fCtlText,canvasModel)); + fCtlText.setLayoutData(new GridData(GridData.FILL_BOTH)); fCtlText.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true)); diff --git a/terminal/org.eclipse.tm.terminal/src/org/eclipse/tm/internal/terminal/textcanvas/TextCanvas.java b/terminal/org.eclipse.tm.terminal/src/org/eclipse/tm/internal/terminal/textcanvas/TextCanvas.java index 97fd807f891..032e8d8c2a3 100644 --- a/terminal/org.eclipse.tm.terminal/src/org/eclipse/tm/internal/terminal/textcanvas/TextCanvas.java +++ b/terminal/org.eclipse.tm.terminal/src/org/eclipse/tm/internal/terminal/textcanvas/TextCanvas.java @@ -33,7 +33,7 @@ import org.eclipse.swt.widgets.Composite; public class TextCanvas extends GridCanvas { protected final ITextCanvasModel fCellCanvasModel; /** Renders the cells */ - private ILinelRenderer fCellRenderer; + private final ILinelRenderer fCellRenderer; private boolean fScrollLock; private Point fDraggingStart; private Point fDraggingEnd; @@ -44,8 +44,11 @@ public class TextCanvas extends GridCanvas { * Create a new CellCanvas with the given SWT style bits. * (SWT.H_SCROLL and SWT.V_SCROLL are automatically added). */ - public TextCanvas(Composite parent, ITextCanvasModel model, int style) { + public TextCanvas(Composite parent, ITextCanvasModel model, int style,ILinelRenderer cellRenderer) { super(parent, style | SWT.H_SCROLL | SWT.V_SCROLL); + fCellRenderer=cellRenderer; + setCellWidth(fCellRenderer.getCellWidth()); + setCellHeight(fCellRenderer.getCellHeight()); fCellCanvasModel=model; fCellCanvasModel.addCellCanvasModelListener(new ITextCanvasModelListener(){ public void cellSizeChanged() { @@ -137,11 +140,6 @@ public class TextCanvas extends GridCanvas { return -1; } } - public void setCellRenderer(ILinelRenderer cellRenderer) { - fCellRenderer = cellRenderer; - setCellWidth(fCellRenderer.getCellWidth()); - setCellHeight(fCellRenderer.getCellHeight()); - } public ILinelRenderer getCellRenderer() { return fCellRenderer; } diff --git a/terminal/org.eclipse.tm.terminal/src/org/eclipse/tm/internal/terminal/textcanvas/TextLineRenderer.java b/terminal/org.eclipse.tm.terminal/src/org/eclipse/tm/internal/terminal/textcanvas/TextLineRenderer.java index 54180496f8f..3b0ead33250 100644 --- a/terminal/org.eclipse.tm.terminal/src/org/eclipse/tm/internal/terminal/textcanvas/TextLineRenderer.java +++ b/terminal/org.eclipse.tm.terminal/src/org/eclipse/tm/internal/terminal/textcanvas/TextLineRenderer.java @@ -24,14 +24,12 @@ import org.eclipse.tm.terminal.model.Style; * */ public class TextLineRenderer implements ILinelRenderer { - TextCanvas fCanvas; private final ITextCanvasModel fModel; StyleMap fStyleMap=new StyleMap(); Color fBackgroundColor; public TextLineRenderer(TextCanvas c, ITextCanvasModel model) { - fCanvas=c; fModel=model; - fBackgroundColor=c.getDisplay().getSystemColor(SWT.COLOR_LIST_BACKGROUND); + fBackgroundColor=Display.getCurrent().getSystemColor(SWT.COLOR_LIST_BACKGROUND); } /* (non-Javadoc) * @see com.imagicus.thumbs.view.ICellRenderer#getCellWidth()