提交 c3b50c3f 编写于 作者: 丁劲犇's avatar 丁劲犇 😸

解决内存越界导致的崩溃

上级 f8b6233e
......@@ -301,7 +301,10 @@ void DialogPlots::on_pushButton_reset_clicked()
if (min_y < new_min_y) new_min_y = min_y,needup_y=true;
if (min_y > new_min_y * 1.2) new_min_y = min_y,needup_y=true;
if (max_x >=1e9 || max_x <-1e9 || max_y >1e9 ||max_y < -1e9 || max_x - min_x <1e-8)
needup_x = false,needup_y = false;
if (min_y >=1e9 || min_y <-1e9 || min_x >1e9 ||min_x < -1e9|| max_y - min_y <1e-8)
needup_x = false,needup_y = false;
if (needup_x==true)
ax->setRange(new_min_x,new_max_x);
......@@ -367,7 +370,7 @@ void DialogPlots::timerEvent(QTimerEvent *event)
for (QList<QVector<double> >::iterator pit = avgList.begin();pit!=avgList.end();++pit)
{
for (int i=0;i<pts;++i)
fdata[i] += pit->at(i)/avgsz;
fdata[i] += pit->at(i)/(avgsz+1e-14);
}
double max_x = 0, max_y = fdata[0];
......@@ -382,7 +385,7 @@ void DialogPlots::timerEvent(QTimerEvent *event)
{
SpectroWidget * ws = m_chat_spec[subid];
QVector<QPointF> vec_points;
for (int i=0;i<pts;i+=step)
for (int i=0;i<pts/channels;i+=step)
{
double x,y;
if (channels==1)
......@@ -397,6 +400,9 @@ void DialogPlots::timerEvent(QTimerEvent *event)
if (y<min_y) min_y = y;
}
if (!(max_x >=1e9 || max_x <-1e9 || max_y >1e9 ||max_y < -1e9 || max_x - min_x <1e-8)||
(min_y >=1e9 || min_y <-1e9 || min_x >1e9 ||min_x < -1e9|| max_y - min_y <1e-8))
{
serials->replace(vec_points);
if (ws)
{
......@@ -418,6 +424,7 @@ void DialogPlots::timerEvent(QTimerEvent *event)
}
}
}
......@@ -438,7 +445,8 @@ void DialogPlots::timerEvent(QTimerEvent *event)
if (y<min_y) min_y = y;
}
if (!(max_x >=1e9 || max_x <-1e9 || max_y >1e9 ||max_y < -1e9 || max_x - min_x <1e-8)||
(min_y >=1e9 || min_y <-1e9 || min_x >1e9 ||min_x < -1e9|| max_y - min_y <1e-8))
serials->replace(lstpts);
}
......@@ -465,6 +473,10 @@ void DialogPlots::timerEvent(QTimerEvent *event)
if (min_y < new_min_y) new_min_y = min_y,needup_y=true;
if (min_y > new_min_y * 1.2) new_min_y = min_y,needup_y=true;
if (max_x >=1e9 || max_x <-1e9 || max_y >1e9 ||max_y < -1e9 || max_x - min_x <1e-8)
needup_x = false,needup_y = false;
if (min_y >=1e9 || min_y <-1e9 || min_x >1e9 ||min_x < -1e9|| max_y - min_y <1e-8)
needup_x = false,needup_y = false;
if (ui->checkBox_auto_reser->isChecked() || needup_x)
{
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册