Community
Participate
Working Groups
Build Identifier: i just switched branches on current nightly (1.3.0.201201162014) and i got this exception from the history view ("error while notifying a preference changed listener" or something like that was displayed). org.eclipse.swt.SWTException: Invalid thread access at org.eclipse.swt.SWT.error(SWT.java:4282) at org.eclipse.swt.SWT.error(SWT.java:4197) at org.eclipse.swt.SWT.error(SWT.java:4168) at org.eclipse.swt.widgets.Widget.error(Widget.java:466) at org.eclipse.swt.widgets.Widget.checkWidget(Widget.java:404) at org.eclipse.swt.widgets.Table.deselectAll(Table.java:956) at org.eclipse.jface.viewers.TableViewer.doDeselectAll(TableViewer.java:277) at org.eclipse.jface.viewers.AbstractTableViewer.setSelectionToWidget(AbstractTableViewer.java:880) at org.eclipse.jface.viewers.StructuredViewer.setSelectionToWidget(StructuredViewer.java:1769) at org.eclipse.jface.viewers.StructuredViewer.preservingSelection(StructuredViewer.java:1450) at org.eclipse.jface.viewers.StructuredViewer.preservingSelection(StructuredViewer.java:1404) at org.eclipse.jface.viewers.StructuredViewer.refresh(StructuredViewer.java:1506) at org.eclipse.jface.viewers.ColumnViewer.refresh(ColumnViewer.java:537) at org.eclipse.jface.viewers.StructuredViewer.refresh(StructuredViewer.java:1465) at org.eclipse.egit.ui.internal.history.GitHistoryPage$1.propertyChange(GitHistoryPage.java:602) at org.eclipse.ui.preferences.ScopedPreferenceStore$3.run(ScopedPreferenceStore.java:375) at org.eclipse.core.runtime.SafeRunner.run(SafeRunner.java:42) at org.eclipse.ui.preferences.ScopedPreferenceStore.firePropertyChangeEvent(ScopedPreferenceStore.java:372) at org.eclipse.ui.preferences.ScopedPreferenceStore$2.preferenceChange(ScopedPreferenceStore.java:194) at org.eclipse.core.internal.preferences.EclipsePreferences$2.run(EclipsePreferences.java:754) at org.eclipse.core.runtime.SafeRunner.run(SafeRunner.java:42) at org.eclipse.core.internal.preferences.EclipsePreferences.firePreferenceEvent(EclipsePreferences.java:757) at org.eclipse.core.internal.preferences.EclipsePreferences.put(EclipsePreferences.java:770) at org.eclipse.ui.preferences.ScopedPreferenceStore.setValue(ScopedPreferenceStore.java:789) at org.eclipse.egit.ui.internal.branch.BranchProjectTracker.save(BranchProjectTracker.java:163) at org.eclipse.egit.ui.internal.branch.BranchOperationUI$1$2.postExecute(BranchOperationUI.java:194) at org.eclipse.egit.core.op.BaseOperation.postExecute(BaseOperation.java:59) at org.eclipse.egit.core.op.BranchOperation$1.run(BranchOperation.java:117) at org.eclipse.core.internal.resources.Workspace.run(Workspace.java:2344) at org.eclipse.core.internal.resources.Workspace.run(Workspace.java:2326) at org.eclipse.egit.core.op.BranchOperation.execute(BranchOperation.java:123) at org.eclipse.egit.ui.internal.branch.BranchOperationUI$1.run(BranchOperationUI.java:199) at org.eclipse.core.internal.jobs.Worker.run(Worker.java:54) Reproducible: Sometimes Steps to Reproduce: 1. switch branches it does not happen always... :( i think there is a syncExec missing in the propertyChange handler in the GitHistoryPage... that should fix it.
proposed fix at http://egit.eclipse.org/r/#change,4967
> i think there is a syncExec missing in the propertyChange handler in the > GitHistoryPage... Nope, this is not needed. The wrong merge for bug 368526 causes the IAE.
(In reply to comment #2) > > i think there is a syncExec missing in the propertyChange handler in the > > GitHistoryPage... > > Nope, this is not needed. The wrong merge for bug 368526 causes the IAE. That code should survive being called at any time, with a change in the setting or not, so a (a)sycnexec is needed for that reason, if not for your particular call sequence.
Why is a change in the relative date setting, published?
(In reply to comment #4) > Why is a change in the relative date setting, published? It is not, that's the point. Here's how the old code looked like: if (UIPreferences.RESOURCEHISTORY_SHOW_RELATIVE_DATE.equals(event .getProperty())) if (graph.setRelativeDate(((Boolean) event.getNewValue()) .booleanValue())) graph.getTableView().refresh(); Yes, not easy readable without braces and with bad indentation. Basically, the refresh only happened if the event was for RESOURCEHISTORY_SHOW_RELATIVE_DATE property and only if the value changed. You changed the code to *always* call refresh() no matter what the property is: if (UIPreferences.RESOURCEHISTORY_SHOW_RELATIVE_DATE.equals(event .getProperty())) graph.setRelativeDate(isShowingRelativeDates()); graph.getTableView().refresh(); The latest suggested patch at least only updates when the property matches but it sill updates when the value remains the same. Also, the relative date setting is a UI property that gets changed via UI preference (in the UI thread). Hence that code always worked in the past. Adding a (a)syncExec is not needed. The correct code should be as indicated in my very first patch: if (UIPreferences.RESOURCEHISTORY_SHOW_RELATIVE_DATE.equals(event .getProperty())) if (graph.setRelativeDate(isShowingRelativeDates())) graph.getTableView().refresh(); }
phew. is it absolutely unthinkable that such properties will be changed in the future from a background thread? i think of some "preference import job" or something like that... i'd still sleep better if an [a]syncExec would be there. at least a big fat // WARNING: should be there i think...
> if (graph.setRelativeDate(isShowingRelativeDates())) OK, I see that this no longer works since the signature of setRelativeDate(...) got changed. I'll upload a new patch.
(In reply to comment #6) > phew. is it absolutely unthinkable that such properties will be changed in the > future from a background thread? i think of some "preference import job" or > something like that... i'd still sleep better if an [a]syncExec would be there. > at least a big fat // WARNING: should be there i think... It's a bit a gray area but the general rule is that those *calling* UI code (which a property change listener is, since it comes from JFace) are responsible to only call it in the UI thread. That's why e.g. the preference import happens in the UI thread and not in a job. On the other hand, if one knows/expects that the code is called from any thread then an (a)syncExec makes sense. I generally try to avoid polluting the code with (a)syncExec if possible. This is for two reasons: 1) It can cause deadlocks. 2) It can change the event flow/order and cause ugly things which are hard to debug.
(In reply to comment #5) > The correct code should be as indicated in my very first patch: > > if (UIPreferences.RESOURCEHISTORY_SHOW_RELATIVE_DATE.equals(event > .getProperty())) > if (graph.setRelativeDate(isShowingRelativeDates())) > graph.getTableView().refresh(); > } Aaaaahh.. You're absolutely right.
The change got merged.
Verified in 1.3.0.201201181724.
*** Bug 369418 has been marked as a duplicate of this bug. ***