[
https://issues.apache.org/jira/browse/PIVOT-780?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13079354#comment-13079354
]
Noel Grandin commented on PIVOT-780:
------------------------------------
Modifying any WTK object from outside the event thread could lead to
data-corruption, which tends to show up as weird errors far away from the
misbehaving code.
That is why we try to catch the offending code early on, to save ourselves from
that debugging.
You can already override the check - see
Container#setEventDispatchThreadChecker()
> Can't use BXMLSerializer from non-AWT threads makes background resource
> loading impossible
> ------------------------------------------------------------------------------------------
>
> Key: PIVOT-780
> URL: https://issues.apache.org/jira/browse/PIVOT-780
> Project: Pivot
> Issue Type: Bug
> Components: core-beans, wtk
> Affects Versions: 2.0.1
> Reporter: Piotr Kołaczkowski
> Labels: background, initialization, thread
> Fix For: 2.0.1
>
>
> Calling bxmlSerializer.readObject from a non-AWT thread causes the following
> exception:
> An error occurred at line number 5 in file
> /C:/Users/Piotr/Projekty/viungo/viungo-editor/target/scala_2.9.0/classes/com/viungo/editor/CircuitEditor.bxml:
> org.apache.pivot.serialization.SerializationException:
> java.lang.IllegalStateException: this method can only be called from the AWT
> event dispatch thread
> at
> org.apache.pivot.beans.BXMLSerializer.processStartElement(BXMLSerializer.java:769)
> at
> org.apache.pivot.beans.BXMLSerializer.readObject(BXMLSerializer.java:441)
> at
> org.apache.pivot.beans.BXMLSerializer.readObject(BXMLSerializer.java:624)
> at
> org.apache.pivot.beans.BXMLSerializer.readObject(BXMLSerializer.java:579)
> at
> org.apache.pivot.beans.BXMLSerializer.readObject(BXMLSerializer.java:540)
> at
> com.viungo.editor.CircuitEditor$$anon$1.execute(CircuitEditor.scala:21)
> at
> com.viungo.editor.CircuitEditor$$anon$1.execute(CircuitEditor.scala:18)
> at
> org.apache.pivot.util.concurrent.Task$ExecuteCallback.run(Task.java:42)
> at
> java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:441)
> at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:303)
> at java.util.concurrent.FutureTask.run(FutureTask.java:138)
> at java.lang.Thread.run(Thread.java:662)
> Caused by: java.lang.IllegalStateException: this method can only be called
> from the AWT event dispatch thread
> at org.apache.pivot.wtk.Container$1.run(Container.java:864)
> at
> org.apache.pivot.wtk.Container.assertEventDispatchThread(Container.java:871)
> at org.apache.pivot.wtk.WTKListenerList.add(WTKListenerList.java:36)
> at
> org.apache.pivot.wtk.skin.ComponentSkin.install(ComponentSkin.java:96)
> at
> org.apache.pivot.wtk.skin.ContainerSkin.install(ContainerSkin.java:129)
> at org.apache.pivot.wtk.skin.WindowSkin.install(WindowSkin.java:66)
> at org.apache.pivot.wtk.Component.setSkin(Component.java:749)
> at org.apache.pivot.wtk.Component.installSkin(Component.java:812)
> at org.apache.pivot.wtk.Window.<init>(Window.java:453)
> at org.apache.pivot.wtk.Window.<init>(Window.java:448)
> at com.viungo.editor.EditorWindow.<init>(EditorWindow.scala:20)
> at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
> at
> sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:39)
> at
> sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:27)
> at java.lang.reflect.Constructor.newInstance(Constructor.java:513)
> at java.lang.Class.newInstance0(Class.java:355)
> at java.lang.Class.newInstance(Class.java:308)
> at
> org.apache.pivot.beans.BXMLSerializer.newTypedObject(BXMLSerializer.java:1556)
> at
> org.apache.pivot.beans.BXMLSerializer.processStartElement(BXMLSerializer.java:767)
> ... 11 more
> Loading objects in background is very important, so that the user can see
> e.g. a progress indicator while the rest of the UI is deserialized.
> Doing this in AWT thread, blocks what is currently displayed.
--
This message is automatically generated by JIRA.
For more information on JIRA, see: http://www.atlassian.com/software/jira