TAChart: two problems with notification broadcasting
Original Reporter info from Mantis: Marcin Wiazowski
-
Reporter name:
Original Reporter info from Mantis: Marcin Wiazowski
- Reporter name:
Description:
When data source is changed, it notifies all its clients of this. But there are two problems with the notification code:
-
Client can remove itself from the notification list just at the moment when it's being notified - this changes list's contents, but is not taken into account by the notification procedure. This leads to omissions when notifying.
-
Client can raise an exception just at the moment when it's being notified - which breaks the notification procedure prematurely. This leads to omissions when notifying.
The attached Reproduce application has three charts, each with one line series. All series have same source (ListChartSource). Pressing a "Test" button changes ListChartSource's YCount to zero, thus making the source improper for line series. In this case, first notified series reverts to its built-in source (so it disappears from the chart) and raises an exception - which breaks the notification chain. As a consequence, the other two series still use (already invalid) source. Pressing the "Test" button again repeats this behavior, making the next series reverting to its built-in source, disappearing from the chart and raising an exception. The third attempt removes the last series from the chart.
The problem can be also reproduced in IDE, when changing ListChartSource's YCount to 0 and then back to 1, and again, and again.
The attached patch solves both 1) and 2) problems. It catches all the exceptions raised during the notification process, and then raises a one, common exception. Thanks to using a "dupIgnore" option, same exception messages are reported only once.
After applying the patch and pressing the "Test" button, all three series disappear at the same moment from their charts.