From 25b30da2446d9daf8343c246056b207d285582e7 Mon Sep 17 00:00:00 2001 From: Berthold Stoeger Date: Sun, 25 Aug 2019 12:56:41 +0200 Subject: Profile: properly initialize plot_info structures The create_plot_info_new() function releases old plot data. This can only work if the plot_info structure was initialized previously. The ProfileWidget2 did that by a memset, but other parts of the code did not. Therefore, introduce a init_plot_info() function and call that when generating a plot_info struct. Constructors would make this so much easier - but since this is called from C, we can't use them. Fixes #2251 Signed-off-by: Berthold Stoeger --- profile-widget/profilewidget2.cpp | 2 +- profile-widget/ruleritem.cpp | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) (limited to 'profile-widget') diff --git a/profile-widget/profilewidget2.cpp b/profile-widget/profilewidget2.cpp index f3dfb8ce9..bde470fd7 100644 --- a/profile-widget/profilewidget2.cpp +++ b/profile-widget/profilewidget2.cpp @@ -148,7 +148,7 @@ ProfileWidget2::ProfileWidget2(QWidget *parent) : QGraphicsView(parent), // would like to be able to ASSERT here that PreferencesDialog::loadSettings has been called. isPlotZoomed = prefs.zoomed_plot; // now it seems that 'prefs' has loaded our preferences - memset(&plotInfo, 0, sizeof(plotInfo)); + init_plot_info(&plotInfo); setupSceneAndFlags(); setupItemSizes(); diff --git a/profile-widget/ruleritem.cpp b/profile-widget/ruleritem.cpp index f489aa9dd..3e61790ad 100644 --- a/profile-widget/ruleritem.cpp +++ b/profile-widget/ruleritem.cpp @@ -17,7 +17,7 @@ RulerNodeItem2::RulerNodeItem2() : timeAxis(NULL), depthAxis(NULL) { - memset(&pInfo, 0, sizeof(pInfo)); + init_plot_info(&pInfo); setRect(-8, -8, 16, 16); setBrush(QColor(0xff, 0, 0, 127)); setPen(QColor(Qt::red)); -- cgit v1.2.3-70-g09d2