SitePen / dgrid

A lightweight, mobile-ready, data-driven, modular grid widget designed for use with dstore
http://dgrid.io/
Other
628 stars 298 forks source link

Fix memory leak when ColumnSet is used with Editor #1455

Closed msssk closed 4 years ago

msssk commented 4 years ago

Editor#_configColumns was written with the expectation that _configColumns() would only be invoked once when the columns are set. ColumnSet#configStructure calls _configColumns for each column set, which causes Editor to lose track of editor widgets when the _alwaysOnWidgetColumns array is destructively initialized.

This PR moves initialization of the _alwaysOnWidgetColumns array into configStructure to ensure it is initialized when appropriate and not destructively over-written. Analysis of the sequence of events when a grid is created with both ColumnSet and Editor points to this as the best point in the code to land the fix despite the fact that it only works if ColumnSet is mixed in before Editor. To enforce this mixin order the ColumnSet constructor will throw an error if it detects that Editor's constructor has already executed. This requirement is also added to the documentation for ColumnSet.

Fixes #1412