protect frame-picker destroy if frame picker init() was not called

This commit is contained in:
juliandescottes 2017-05-06 19:16:20 +02:00 committed by Julian Descottes
parent a72b0c69e5
commit 00d4a1614b
4 changed files with 11 additions and 4 deletions

View File

@ -23,6 +23,10 @@
};
ns.AbstractImportStep.prototype.destroy = function () {
if (this.framePickerWidget) {
this.framePickerWidget.destroy();
}
pskl.utils.Event.removeAllEventListeners(this);
};

View File

@ -35,7 +35,10 @@
};
ns.InsertLocation.prototype.onShow = function () {
// Initialize the frame picker on show, to be able to calculate correctly the
// container's offsetWidth and offsetHeight.
this.currentPiskelFramePickerWidget.init();
var currentFrameIndex = this.piskelController.getCurrentFrameIndex();
this.currentPiskelFramePickerWidget.setFrameIndex(currentFrameIndex + 1);
this.currentPiskelFramePickerWidget.setFirstFrameIndex(0);

View File

@ -28,9 +28,6 @@
};
ns.SelectMode.prototype.destroy = function () {
if (this.framePickerWidget) {
this.framePickerWidget.destroy();
}
this.superclass.destroy.call(this);
};

View File

@ -59,7 +59,10 @@
};
ns.FramePicker.prototype.destroy = function () {
this.container.removeChild(this.wrapper);
if (this.wrapper.parentNode) {
this.wrapper.parentNode.removeChild(this.wrapper);
}
pskl.utils.Event.removeAllEventListeners(this);
};