From c0ed2122f4eca7ed5f21e0a3f287692e58c3b771 Mon Sep 17 00:00:00 2001 From: Barth Netterfield Date: Thu, 4 Dec 2014 00:22:49 -0500 Subject: [PATCH] Fix crash in Zoom Mean Centered and shared axis boxes. --- src/libkstapp/plotitem.cpp | 4 ++-- src/libkstapp/sharedaxisboxitem.cpp | 11 ++++++----- src/libkstapp/sharedaxisboxitem.h | 2 +- 3 files changed, 9 insertions(+), 8 deletions(-) diff --git a/src/libkstapp/plotitem.cpp b/src/libkstapp/plotitem.cpp index 615cf169f..09bc49eb0 100644 --- a/src/libkstapp/plotitem.cpp +++ b/src/libkstapp/plotitem.cpp @@ -3075,7 +3075,7 @@ void PlotItem::zoomMeanCentered(bool force) { void PlotItem::zoomYMeanCentered(qreal dY, bool force) { if (isInSharedAxisBox() && !force) { - sharedAxisBox()->zoomYMeanCentered(this); + sharedAxisBox()->zoomYMeanCentered(dY, this); } else { ZoomCommand *cmd = new ZoomYMeanCenteredCommand(this, dY, force); _undoStack->push(cmd); @@ -4099,7 +4099,7 @@ void ZoomYMeanCenteredCommand::applyZoomTo(ViewItem *item, bool applyX, bool app SharedAxisBoxItem *shareBox = qobject_cast(item); if (shareBox) { if (applyY) { - shareBox->zoomYMeanCentered(0); + shareBox->zoomYMeanCentered(_dY, 0); } } } diff --git a/src/libkstapp/sharedaxisboxitem.cpp b/src/libkstapp/sharedaxisboxitem.cpp index e13755bde..e10f0f50a 100644 --- a/src/libkstapp/sharedaxisboxitem.cpp +++ b/src/libkstapp/sharedaxisboxitem.cpp @@ -594,12 +594,13 @@ void SharedAxisBoxItem::zoomMeanCentered(PlotItem* originPlotItem) { applyZoom(computeRect(PlotAxis::Auto, PlotAxis::MeanCentered), originPlotItem, false, true); } -void SharedAxisBoxItem::zoomYMeanCentered(PlotItem* originPlotItem) { - _yAxisZoomMode = PlotAxis::MeanCentered; - if (originPlotItem) { - originPlotItem->zoomYMeanCentered(true); +void SharedAxisBoxItem::zoomYMeanCentered(qreal dY, PlotItem* originPlotItem) { + if (!_shareY) { + _yAxisZoomMode = PlotAxis::MeanCentered; + if (originPlotItem) { + originPlotItem->zoomYMeanCentered(dY, true); + } } - applyZoom(computeRect(PlotAxis::Auto, PlotAxis::MeanCentered), originPlotItem, false, true); } void SharedAxisBoxItem::zoomXMeanCentered(PlotItem* originPlotItem) { diff --git a/src/libkstapp/sharedaxisboxitem.h b/src/libkstapp/sharedaxisboxitem.h index 6e737044a..d57c7672d 100644 --- a/src/libkstapp/sharedaxisboxitem.h +++ b/src/libkstapp/sharedaxisboxitem.h @@ -87,7 +87,7 @@ class SharedAxisBoxItem : public ViewItem void zoomNormalizeXtoY(PlotItem* originPlotItem); void zoomLogX(PlotItem* originPlotItem, bool autoEnable = true, bool enable = true); - void zoomYMeanCentered(PlotItem* originPlotItem); + void zoomYMeanCentered(qreal dY, PlotItem* originPlotItem); void zoomYLocalMaximum(PlotItem* originPlotItem); void zoomYMaximum(PlotItem* originPlotItem); void zoomYNoSpike(PlotItem* originPlotItem);