Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixed error while we call adjusting size or make full update simultaneously #456

Merged
merged 2 commits into from
May 28, 2020
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Don't call adjustSize and don't make full update simultaneously
timocov committed May 26, 2020

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature.
commit 333ee505481c46c7c28930cbc22e9fccbcd47e7a
9 changes: 3 additions & 6 deletions src/gui/chart-widget.ts
Original file line number Diff line number Diff line change
@@ -105,6 +105,7 @@ export class ChartWidget implements IDestroyable {
container.appendChild(this._element);
this._updateTimeAxisVisibility();
this._model.timeScale().optionsApplied().subscribe(this._model.fullUpdate.bind(this._model), this);
this._model.priceScalesOptionsChanged().subscribe(this._model.fullUpdate.bind(this._model), this);
}

public model(): ChartModel {
@@ -127,6 +128,7 @@ export class ChartWidget implements IDestroyable {

this._model.crosshairMoved().unsubscribeAll(this);
this._model.timeScale().optionsApplied().unsubscribeAll(this);
this._model.priceScalesOptionsChanged().unsubscribeAll(this);
this._model.destroy();

for (const paneWidget of this._paneWidgets) {
@@ -189,11 +191,6 @@ export class ChartWidget implements IDestroyable {
this._timeAxisWidget.paint(invalidateMask.fullInvalidation());
}

public adjustSize(): void {
this._adjustSizeImpl();
this._model.fullUpdate();
}

public applyOptions(options: DeepPartial<ChartOptionsInternal>): void {
this._model.applyOptions(options);
this._updateTimeAxisVisibility();
@@ -546,7 +543,7 @@ export class ChartWidget implements IDestroyable {
if (paneWidget.state() !== state) {
paneWidget.setState(state);
} else {
paneWidget.updatePriceAxisWidget();
paneWidget.updatePriceAxisWidgets();
}
}

2 changes: 1 addition & 1 deletion src/gui/pane-separator.ts
Original file line number Diff line number Diff line change
@@ -119,7 +119,7 @@ export class PaneSeparator implements IDestroyable {
this._paneA.setStretchFactor(newUpperPaneStretch);
this._paneB.setStretchFactor(newLowerPaneStretch);

this._chartWidget.adjustSize();
this._chartWidget.model().fullUpdate();

if (this._paneA.getSize().h !== upperHeight) {
this._startY = event.pageY;
16 changes: 5 additions & 11 deletions src/gui/pane-widget.ts
Original file line number Diff line number Diff line change
@@ -103,9 +103,7 @@ export class PaneWidget implements IDestroyable {
this._rowElement.appendChild(this._leftAxisCell);
this._rowElement.appendChild(this._paneCell);
this._rowElement.appendChild(this._rightAxisCell);
this._recreatePriceAxisWidgetImpl();
chart.model().priceScalesOptionsChanged().subscribe(this._recreatePriceAxisWidget.bind(this), this);
this.updatePriceAxisWidget();
this.updatePriceAxisWidgets();

const scrollOptions = this.chart().options().handleScroll;
this._mouseEventHandler = new MouseEventHandler(
@@ -158,7 +156,7 @@ export class PaneWidget implements IDestroyable {
this._state.onDestroyed().subscribe(PaneWidget.prototype._onStateDestroyed.bind(this), this, true);
}

this.updatePriceAxisWidget();
this.updatePriceAxisWidgets();
}

public chart(): ChartWidget {
@@ -169,11 +167,12 @@ export class PaneWidget implements IDestroyable {
return this._rowElement;
}

public updatePriceAxisWidget(): void {
public updatePriceAxisWidgets(): void {
if (this._state === null) {
return;
}

this._recreatePriceAxisWidgets();
if (this._model().serieses().length === 0) {
return;
}
@@ -654,12 +653,7 @@ export class PaneWidget implements IDestroyable {
return null;
}

private _recreatePriceAxisWidget(): void {
this._recreatePriceAxisWidgetImpl();
this._chart.adjustSize();
}

private _recreatePriceAxisWidgetImpl(): void {
private _recreatePriceAxisWidgets(): void {
if (this._state === null) {
return;
}