1

我有一个基于 SWT 的桌面应用程序。我有一棵包含在 ScrolledComposite 中的树。应用程序中的这段代码应该刷新 ui 组件。

aTreeViewer.setInput(this.items) //items is an array list of relevant objects

但它在 Windows XP 和 Windows 7 上的行为很奇怪。在 Win XP 中,它返回一个硬 ArrayIndexOutofBounds 异常,该异常会影响我的应用程序的行为。

java.lang.ArrayIndexOutOfBoundsException: 46
       at org.eclipse.swt.widgets.Tree._getItem(Tree.java:254)
       at org.eclipse.swt.widgets.Tree._getItem(Tree.java:248)
       at org.eclipse.swt.widgets.Tree.findCell(Tree.java:2703)
       at org.eclipse.swt.widgets.Tree.WM_MOUSEMOVE(Tree.java:6806)
       at org.eclipse.swt.widgets.Control.windowProc(Control.java:4575)
       at org.eclipse.swt.widgets.Tree.windowProc(Tree.java:5958)
       at org.eclipse.swt.widgets.Display.windowProc(Display.java:4989)
       at org.eclipse.swt.internal.win32.OS.DispatchMessageW(Native Method)
       at org.eclipse.swt.internal.win32.OS.DispatchMessage(OS.java:2546)
       at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java:3756)

而在 Win 7 上,它似乎从 SWT 层返回此消息,该消息似乎是在我的 Eclipse 控制台上打印的 RunTimeException,但绝不会影响应用程序的行为。意思是,应用程序运行良好。

Ignored reentrant call while viewer is busy. This is only logged once per viewer instance, but similar calls will still be ignored.
java.lang.RuntimeException
       at org.eclipse.jface.viewers.ColumnViewer.checkBusy(ColumnViewer.java:763)
       at org.eclipse.jface.viewers.ColumnViewer.refresh(ColumnViewer.java:541)
       at org.eclipse.jface.viewers.StructuredViewer.refresh(StructuredViewer.java:1490)
       at com.sxsy.smtj.ui.cw.widgets.EwList.basicRefresh(EwList.java:86)
       at com.sxsy.smtj.ui.cw.widgets.EwTableList.basicRefresh(EwTableList.java:75)
       at com.sxsy.smtj.ui.cw.widgets.EwList.refresh(EwList.java:402)
       at com.sxsy.smtj.ui.cw.widgets.EwTableList.columnsChanged(EwTableList.java:115)
       at com.sxsy.smtj.ui.cw.widgets.EwTableColumn.updateWidget(EwTableColumn.java:377)
       at com.sxsy.smtj.ui.cw.widgets.EwTableColumn.width(EwTableColumn.java:407)
       at com.sxsy.smtj.ui.cw.widgets.WkTableWidget.doAutoSizeColumns(WkTableWidget.java:244)
       at com.sxsy.smtj.ui.cw.widgets.WkTableWidget.autoSizeColumns(WkTableWidget.java:87)
       at com.sxsy.smtj.ui.cw.widgets.WkTableWidget.processResizedEvent(WkTableWidget.java:437)
       at com.sxsy.smtj.ui.cw.widgets.EwList$3.controlResized(EwList.java:449)
       at org.eclipse.swt.widgets.TypedListener.handleEvent(TypedListener.java:235)
       at org.eclipse.swt.widgets.EventTable.sendEvent(EventTable.java:84)
       at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:1053)
       at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:1077)
       at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:1058)
       at org.eclipse.swt.widgets.Tree.windowProc(Tree.java:5795)
       at org.eclipse.swt.widgets.Display.windowProc(Display.java:4976)
       at org.eclipse.swt.internal.win32.OS.DefWindowProcW(Native Method)
       at org.eclipse.swt.internal.win32.OS.DefWindowProc(OS.java:2541)
       at org.eclipse.swt.widgets.Tree.callWindowProc(Tree.java:1442)
       at org.eclipse.swt.widgets.Tree.windowProc(Tree.java:5859)
       at org.eclipse.swt.widgets.Display.windowProc(Display.java:4976)
       at org.eclipse.swt.internal.win32.OS.SetScrollInfo(Native Method)
       at org.eclipse.swt.widgets.Tree.updateScrollBar(Tree.java:5660)
       at org.eclipse.swt.widgets.Tree.callWindowProc(Tree.java:1589)
       at org.eclipse.swt.widgets.Scrollable.WM_SIZE(Scrollable.java:316)
       at org.eclipse.swt.widgets.Composite.WM_SIZE(Composite.java:1662)
       at org.eclipse.swt.widgets.Tree.WM_SIZE(Tree.java:7137)
       at org.eclipse.swt.widgets.Control.windowProc(Control.java:4603)
       at org.eclipse.swt.widgets.Tree.windowProc(Tree.java:5958)
       at org.eclipse.swt.widgets.Display.windowProc(Display.java:4976)
       at org.eclipse.swt.internal.win32.OS.CallWindowProcW(Native Method)
       at org.eclipse.swt.internal.win32.OS.CallWindowProc(OS.java:2440)
       at org.eclipse.swt.widgets.Tree.callWindowProc(Tree.java:1534)
       at org.eclipse.swt.widgets.Control.WM_WINDOWPOSCHANGED(Control.java:5408)
       at org.eclipse.swt.widgets.Control.windowProc(Control.java:4616)
       at org.eclipse.swt.widgets.Tree.windowProc(Tree.java:5958)
       at org.eclipse.swt.widgets.Display.windowProc(Display.java:4976)
       at org.eclipse.swt.internal.win32.OS.ShowScrollBar(Native Method)
       at org.eclipse.swt.widgets.Tree.WM_SIZE(Tree.java:7124)
       at org.eclipse.swt.widgets.Control.windowProc(Control.java:4603)
       at org.eclipse.swt.widgets.Tree.windowProc(Tree.java:5958)
       at org.eclipse.swt.widgets.Display.windowProc(Display.java:4976)
       at org.eclipse.swt.internal.win32.OS.CallWindowProcW(Native Method)
       at org.eclipse.swt.internal.win32.OS.CallWindowProc(OS.java:2440)
       at org.eclipse.swt.widgets.Tree.callWindowProc(Tree.java:1534)
       at org.eclipse.swt.widgets.Control.WM_WINDOWPOSCHANGED(Control.java:5408)
       at org.eclipse.swt.widgets.Control.windowProc(Control.java:4616)
       at org.eclipse.swt.widgets.Tree.windowProc(Tree.java:5958)
       at org.eclipse.swt.widgets.Display.windowProc(Display.java:4976)
       at org.eclipse.swt.internal.win32.OS.CallWindowProcW(Native Method)
       at org.eclipse.swt.internal.win32.OS.CallWindowProc(OS.java:2440)
       at org.eclipse.swt.widgets.Tree.callWindowProc(Tree.java:1534)
       at org.eclipse.swt.widgets.Control.windowProc(Control.java:4623)
       at org.eclipse.swt.widgets.Tree.windowProc(Tree.java:5958)
       at org.eclipse.swt.widgets.Display.windowProc(Display.java:4976)
       at org.eclipse.swt.internal.win32.OS.SendMessageW(Native Method)
       at org.eclipse.swt.internal.win32.OS.SendMessage(OS.java:3385)
       at org.eclipse.swt.widgets.Tree.createItem(Tree.java:2104)
       at org.eclipse.swt.widgets.TreeItem.<init>(TreeItem.java:203)
       at org.eclipse.swt.widgets.TreeItem.<init>(TreeItem.java:91)
       at org.eclipse.jface.viewers.TreeViewer.createNewRowPart(TreeViewer.java:809)
       at org.eclipse.jface.viewers.TreeViewer.newItem(TreeViewer.java:315)
       at org.eclipse.jface.viewers.AbstractTreeViewer.createTreeItem(AbstractTreeViewer.java:847)
       at org.eclipse.jface.viewers.AbstractTreeViewer$1.run(AbstractTreeViewer.java:823)
       at org.eclipse.swt.custom.BusyIndicator.showWhile(BusyIndicator.java:70)
       at org.eclipse.jface.viewers.AbstractTreeViewer.createChildren(AbstractTreeViewer.java:797)
       at org.eclipse.jface.viewers.TreeViewer.createChildren(TreeViewer.java:644)
       at org.eclipse.jface.viewers.AbstractTreeViewer.createChildren(AbstractTreeViewer.java:768)
       at org.eclipse.jface.viewers.AbstractTreeViewer.internalInitializeTree(AbstractTreeViewer.java:1548)
       at org.eclipse.jface.viewers.TreeViewer.internalInitializeTree(TreeViewer.java:833)
       at org.eclipse.jface.viewers.AbstractTreeViewer$5.run(AbstractTreeViewer.java:1532)
       at org.eclipse.jface.viewers.StructuredViewer.preservingSelection(StructuredViewer.java:1443)
       at org.eclipse.jface.viewers.TreeViewer.preservingSelection(TreeViewer.java:403)
       at org.eclipse.jface.viewers.StructuredViewer.preservingSelection(StructuredViewer.java:1404)
       at org.eclipse.jface.viewers.AbstractTreeViewer.inputChanged(AbstractTreeViewer.java:1525)
       at org.eclipse.jface.viewers.ContentViewer.setInput(ContentViewer.java:280)
       at org.eclipse.jface.viewers.StructuredViewer.setInput(StructuredViewer.java:1690)
       at com.sxsy.smtj.ui.cw.widgets.EwList.refreshItems(EwList.java:439)
       at com.sxsy.smtj.ui.cw.widgets.EwTableList.refreshItems(EwTableList.java:514)
       at com.sxsy.smtj.ui.cw.widgets.EwTableTree.refreshItems(EwTableTree.java:275)
       at com.sxsy.smtj.ui.cw.widgets.EwList.itemsHaveChanged(EwList.java:345)
       at com.sxsy.smtj.ui.cw.widgets.EwLinearList.itemsHaveChanged(EwLinearList.java:200)
       at com.sxsy.smtj.ui.cw.widgets.EwList.setItems(EwList.java:549)
       at com.sxsy.smtj.ui.cw.widgets.WkTableWidget.setItems(WkTableWidget.java:467)
       at com.sxsy.smtj.ui.abt.widgets.compatibility.ExtendedList.widgetSetItems(ExtendedList.java:574)
       at com.sxsy.smtj.ui.abt.widgets.compatibility.ExtendedList.setItems(ExtendedList.java:479)
       at com.sxsy.smtj.ui.wk.table.compatibility.WkTableWidgetView.setItems(WkTableWidgetView.java:645)
       at com.misys.liq.ui.collateral.LiqCollateralAgreementTypeDefinitionController.updateAttributeGrid(LiqCollateralAgreementTypeDefinitionController.java:1712)
       at com.misys.liq.ui.collateral.LiqCollateralAgreementTypeDefinitionController.showCoreAttributes(LiqCollateralAgreementTypeDefinitionController.java:1730)
       at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
       at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
       at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
       at java.lang.reflect.Method.invoke(Unknown Source)
       at com.sxsy.smtj.utilities.ReflectionUtility.invoke(ReflectionUtility.java:754)
       at com.sxsy.smtj.utilities.ReflectionUtility.directPerform(ReflectionUtility.java:740)
       at com.sxsy.smtj.utilities.ReflectionUtility.perform(ReflectionUtility.java:605)
       at com.sxsy.smtj.compatibility.va.kernel.core.DirectedMessage.performAction(DirectedMessage.java:106)
       at com.misys.liq.infrastructure.EventObservableSupport.signalEvent(EventObservableSupport.java:21)
       at com.sxsy.smtj.ui.abt.ObservableObject.primSignalEvent(ObservableObject.java:324)
       at com.sxsy.smtj.ui.abt.ObservableObject.signalEvent(ObservableObject.java:398)
       at com.sxsy.smtj.ui.abt.widgets.compatibility.BasicView.signalEvent(BasicView.java:1879)
       at com.sxsy.smtj.ui.abt.widgets.compatibility.ToggleButtonView$2.widgetSelected(ToggleButtonView.java:316)
       at org.eclipse.swt.widgets.TypedListener.handleEvent(TypedListener.java:248)
       at org.eclipse.swt.widgets.EventTable.sendEvent(EventTable.java:84)
       at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:1053)
       at org.eclipse.swt.widgets.Display.runDeferredEvents(Display.java:4169)
       at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java:3758)
       at com.misys.liq.LoanIQ$13.value(LoanIQ.java:676)
       at com.sxsy.smtj.exceptions.ExceptionUtility.whenDo(ExceptionUtility.java:99)
       at com.misys.liq.LoanIQ.standardLiqEventLoop(LoanIQ.java:693)
       at com.misys.liq.LoanIQ.desktopTestManualLogIn(LoanIQ.java:924)
       at com.misys.liq.LoanIQ.mainClassic(LoanIQ.java:589)
       at com.misys.liq.LoanIQ.main(LoanIQ.java:309)

我想到的第一件事是将我的 ui 逻辑包装在 Display.asyncExec 的可运行文件中,从而我能够修复 Win XP 中的奇怪行为。

虽然,我不知道内部发生了什么,或者即使我的修复是正确的。如果经历过这种 SWT 怪异的人能对此有所了解,那就太好了。

4

1 回答 1

1

这是一个 swt/jface 错误。此问题的解决方法是在设置实际对象之前将项目设置为空。

aTreeViewer.setInput(null);
aTreeViewer.setInput(this.items);
于 2013-02-13T07:30:08.110 回答