NRE when disposing chart with bound PointsLineSeries3D

A forum dedicated to WPF version of LightningChart Ultimate.

Moderator: Queue Moderators

Post Reply
NielsUll
Posts: 19
Joined: Thu Jan 19, 2017 8:23 am

NRE when disposing chart with bound PointsLineSeries3D

Post by NielsUll » Tue Apr 25, 2017 1:15 pm

Hi!
We are using SemibindableCharting, version 7.2.6.4001.
We have a 3D chart and drawing a PointLineSeries3D with PointsCompact bound to a SeriesPointCompact3D[] array.


When we dispose the chart, we get the error below - it seems the wpf is setting PointsCompact to null and the chart doesn't like that?

Code: Select all

System.NullReferenceException occurred
  HResult=0x80004003
  Message=Object reference not set to an instance of an object.
  Source=Arction.Wpf.SemibindableCharting.LightningChartUltimate
  StackTrace:
   at Arction.Wpf.SemibindableCharting.Series3D.PointLineSeries3D.PointsCompactChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
   at System.Windows.DependencyObject.OnPropertyChanged(DependencyPropertyChangedEventArgs e) in f:\dd\wpf\src\Base\System\Windows\DependencyObject.cs:line 2082
   at System.Windows.Freezable.OnPropertyChanged(DependencyPropertyChangedEventArgs e) in f:\dd\wpf\src\Base\System\Windows\Freezable.cs:line 310
   at System.Windows.DependencyObject.NotifyPropertyChange(DependencyPropertyChangedEventArgs args) in f:\dd\wpf\src\Base\System\Windows\DependencyObject.cs:line 1756
   at System.Windows.DependencyObject.UpdateEffectiveValue(EntryIndex entryIndex, DependencyProperty dp, PropertyMetadata metadata, EffectiveValueEntry oldEntry, EffectiveValueEntry& newEntry, Boolean coerceWithDeferredReference, Boolean coerceWithCurrentValue, OperationType operationType) in f:\dd\wpf\src\Base\System\Windows\DependencyObject.cs:line 1570
   at System.Windows.DependencyObject.InvalidateProperty(DependencyProperty dp, Boolean preserveCurrentValue) in f:\dd\wpf\src\Base\System\Windows\DependencyObject.cs:line 1234
   at System.Windows.Data.BindingExpressionBase.Invalidate(Boolean isASubPropertyChange) in f:\dd\wpf\src\Framework\System\Windows\Data\BindingExpressionBase.cs:line 1519
   at System.Windows.Data.BindingExpression.TransferValue(Object newValue, Boolean isASubPropertyChange) in f:\dd\wpf\src\Framework\System\Windows\Data\BindingExpression.cs:line 1494
   at System.Windows.Data.BindingExpression.Activate(Object item) in f:\dd\wpf\src\Framework\System\Windows\Data\BindingExpression.cs:line 1024
   at System.Windows.Data.BindingExpression.OnDataContextChanged(DependencyObject contextElement) in f:\dd\wpf\src\Framework\System\Windows\Data\BindingExpression.cs:line 2417
   at System.Windows.Data.BindingExpression.HandlePropertyInvalidation(DependencyObject d, DependencyPropertyChangedEventArgs args) in f:\dd\wpf\src\Framework\System\Windows\Data\BindingExpression.cs:line 2644
   at System.Windows.Data.BindingExpressionBase.OnPropertyInvalidation(DependencyObject d, DependencyPropertyChangedEventArgs args) in f:\dd\wpf\src\Framework\System\Windows\Data\BindingExpressionBase.cs:line 449
   at System.Windows.Data.BindingExpression.OnPropertyInvalidation(DependencyObject d, DependencyPropertyChangedEventArgs args) in f:\dd\wpf\src\Framework\System\Windows\Data\BindingExpression.cs:line 255
   at System.Windows.DependentList.InvalidateDependents(DependencyObject source, DependencyPropertyChangedEventArgs sourceArgs) in f:\dd\wpf\src\Base\System\Windows\DependentList.cs:line 63
   at System.Windows.DependencyObject.NotifyPropertyChange(DependencyPropertyChangedEventArgs args) in f:\dd\wpf\src\Base\System\Windows\DependencyObject.cs:line 1777
   at System.Windows.DependencyObject.UpdateEffectiveValue(EntryIndex entryIndex, DependencyProperty dp, PropertyMetadata metadata, EffectiveValueEntry oldEntry, EffectiveValueEntry& newEntry, Boolean coerceWithDeferredReference, Boolean coerceWithCurrentValue, OperationType operationType) in f:\dd\wpf\src\Base\System\Windows\DependencyObject.cs:line 1570
   at System.Windows.DependencyObject.SetValueCommon(DependencyProperty dp, Object value, PropertyMetadata metadata, Boolean coerceWithDeferredReference, Boolean coerceWithCurrentValue, OperationType operationType, Boolean isInternal) in f:\dd\wpf\src\Base\System\Windows\DependencyObject.cs:line 839
   at System.Windows.DependencyObject.SetValue(DependencyProperty dp, Object value) in f:\dd\wpf\src\Base\System\Windows\DependencyObject.cs:line 428
   at Arction.Wpf.SemibindableCharting.LightningChartUltimate.KYB(Boolean A)
   at Arction.Wpf.SemibindableCharting.LightningChartUltimate.Dispose()
BTW, using Points and a SeriesPoint3D[] array instead of PointsCompact gives almost the same error:

Code: Select all

System.NullReferenceException occurred
  HResult=0x80004003
  Message=Object reference not set to an instance of an object.
  Source=Arction.Wpf.SemibindableCharting.LightningChartUltimate
  StackTrace:
   at Arction.Wpf.SemibindableCharting.Series3D.PointLineSeries3D.PointsChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
   at System.Windows.DependencyObject.OnPropertyChanged(DependencyPropertyChangedEventArgs e) in f:\dd\wpf\src\Base\System\Windows\DependencyObject.cs:line 2082
   at System.Windows.Freezable.OnPropertyChanged(DependencyPropertyChangedEventArgs e) in f:\dd\wpf\src\Base\System\Windows\Freezable.cs:line 310
   at System.Windows.DependencyObject.NotifyPropertyChange(DependencyPropertyChangedEventArgs args) in f:\dd\wpf\src\Base\System\Windows\DependencyObject.cs:line 1756
   at System.Windows.DependencyObject.UpdateEffectiveValue(EntryIndex entryIndex, DependencyProperty dp, PropertyMetadata metadata, EffectiveValueEntry oldEntry, EffectiveValueEntry& newEntry, Boolean coerceWithDeferredReference, Boolean coerceWithCurrentValue, OperationType operationType) in f:\dd\wpf\src\Base\System\Windows\DependencyObject.cs:line 1570
   at System.Windows.DependencyObject.InvalidateProperty(DependencyProperty dp, Boolean preserveCurrentValue) in f:\dd\wpf\src\Base\System\Windows\DependencyObject.cs:line 1234
   at System.Windows.Data.BindingExpressionBase.Invalidate(Boolean isASubPropertyChange) in f:\dd\wpf\src\Framework\System\Windows\Data\BindingExpressionBase.cs:line 1519
   at System.Windows.Data.BindingExpression.TransferValue(Object newValue, Boolean isASubPropertyChange) in f:\dd\wpf\src\Framework\System\Windows\Data\BindingExpression.cs:line 1494
   at System.Windows.Data.BindingExpression.Activate(Object item) in f:\dd\wpf\src\Framework\System\Windows\Data\BindingExpression.cs:line 1024
   at System.Windows.Data.BindingExpression.OnDataContextChanged(DependencyObject contextElement) in f:\dd\wpf\src\Framework\System\Windows\Data\BindingExpression.cs:line 2417
   at System.Windows.Data.BindingExpression.HandlePropertyInvalidation(DependencyObject d, DependencyPropertyChangedEventArgs args) in f:\dd\wpf\src\Framework\System\Windows\Data\BindingExpression.cs:line 2644
   at System.Windows.Data.BindingExpressionBase.OnPropertyInvalidation(DependencyObject d, DependencyPropertyChangedEventArgs args) in f:\dd\wpf\src\Framework\System\Windows\Data\BindingExpressionBase.cs:line 449
   at System.Windows.Data.BindingExpression.OnPropertyInvalidation(DependencyObject d, DependencyPropertyChangedEventArgs args) in f:\dd\wpf\src\Framework\System\Windows\Data\BindingExpression.cs:line 255
   at System.Windows.DependentList.InvalidateDependents(DependencyObject source, DependencyPropertyChangedEventArgs sourceArgs) in f:\dd\wpf\src\Base\System\Windows\DependentList.cs:line 63
   at System.Windows.DependencyObject.NotifyPropertyChange(DependencyPropertyChangedEventArgs args) in f:\dd\wpf\src\Base\System\Windows\DependencyObject.cs:line 1777
   at System.Windows.DependencyObject.UpdateEffectiveValue(EntryIndex entryIndex, DependencyProperty dp, PropertyMetadata metadata, EffectiveValueEntry oldEntry, EffectiveValueEntry& newEntry, Boolean coerceWithDeferredReference, Boolean coerceWithCurrentValue, OperationType operationType) in f:\dd\wpf\src\Base\System\Windows\DependencyObject.cs:line 1570
   at System.Windows.DependencyObject.SetValueCommon(DependencyProperty dp, Object value, PropertyMetadata metadata, Boolean coerceWithDeferredReference, Boolean coerceWithCurrentValue, OperationType operationType, Boolean isInternal) in f:\dd\wpf\src\Base\System\Windows\DependencyObject.cs:line 839
   at System.Windows.DependencyObject.SetValue(DependencyProperty dp, Object value) in f:\dd\wpf\src\Base\System\Windows\DependencyObject.cs:line 428
   at Arction.Wpf.SemibindableCharting.LightningChartUltimate.KYB(Boolean A)
   at Arction.Wpf.SemibindableCharting.LightningChartUltimate.Dispose()
   ...
I have been able to reproduce this in your examples - see attached code
Attachments
ExampleBound.zip
(1.76 KiB) Downloaded 466 times

ArctionKestutis
Posts: 555
Joined: Mon Mar 14, 2016 9:22 am

Re: NRE when disposing chart with bound PointsLineSeries3D

Post by ArctionKestutis » Thu Apr 27, 2017 1:41 pm

Yes, indeed example throw the exception then Dispose method is called. However, problem comes not from Chart disposal but, from Chart removal / clearance. Somehow, binding to Points / PointsCompact is the reason for PropertyChange call, where Null check is missing.

The next release of v8.1 will have fix for this NullReferenceException.

As workaround now, you need to brake binding before calling Grid’s Children.Clear() or Children.Remove(Chart). For example,

Code: Select all

Chart.View3D.PointLineSeries3D[0].PointsCompact = new SeriesPointCompact3D[0];

will do the trick

Sorry for inconvenience.
All the best,
Kestutis

Post Reply