}\r
@Override\r
public void unregistered() {\r
- unregisterSubscription(subscription);\r
- subscription = null;\r
+ if(subscription != null) {\r
+ unregisterSubscription(subscription);\r
+ subscription = null;\r
+ }\r
}\r
\r
@SuppressWarnings("unchecked")\r
for(int i = 0; i < variableNames.size(); i++) {\r
for(SysdynResult r : results) { \r
if(experiment instanceof SysdynGameExperiment) {\r
- result[i] = ((SysdynGameExperiment)experiment).getCurrentValue(variableNames.get(i));\r
+ Double d = ((SysdynGameExperiment)experiment).getCurrentValue(variableNames.get(i)); \r
+ result[i] = d != null ? d : 0;\r
} else {\r
SysdynDataSet ds = r.getDataSet(variableNames.get(i));\r
if(ds != null && ds.values != null && ds.values.length > 0) {\r
import org.simantics.db.Session;\r
import org.simantics.db.WriteGraph;\r
import org.simantics.db.common.request.WriteRequest;\r
+import org.simantics.db.common.utils.Logger;\r
import org.simantics.db.exception.DatabaseException;\r
import org.simantics.db.procedure.Listener;\r
import org.simantics.db.request.ExternalRead;\r
return request;\r
}\r
\r
-\r
- public void update() {\r
- T value = variable.getValue();\r
- fireValue(value);\r
- }\r
+ public void update() {\r
+ try {\r
+ T value = variable.getValue();\r
+ fireValue(value);\r
+ } catch (Throwable e) {\r
+ fireException(e);\r
+ }\r
+ }\r
\r
void fireValue(T value) {\r
if (listener != null)\r
void fireException(Throwable t) {\r
if (listener != null && excepted.compareAndSet(false, true))\r
listener.exception(t);\r
+ else\r
+ // Can't invoke listener.exception multiple times, but logging\r
+ // further exceptions anyway.\r
+ Logger.defaultLogError(t);\r
}\r
-\r
+ \r
public void setListener(Listener<T> listener) {\r
this.listener = listener;\r
}\r