Changeset - f2e074e18515
[Not reviewed]
default
0 1 0
Hasan Yavuz ÖZDERYA - 7 years ago 2019-01-22 09:22:16
hy@ozderya.net
fix crash on snapshot display
1 file changed with 15 insertions and 3 deletions:
0 comments (0 inline, 0 general)
src/plotmanager.cpp
Show inline comments
 
/*
 
  Copyright © 2018 Hasan Yavuz Özderya
 
  Copyright © 2019 Hasan Yavuz Özderya
 

	
 
  This file is part of serialplot.
 

	
 
  serialplot is free software: you can redistribute it and/or modify
 
  it under the terms of the GNU General Public License as published by
 
  the Free Software Foundation, either version 3 of the License, or
 
  (at your option) any later version.
 

	
 
  serialplot is distributed in the hope that it will be useful,
 
  but WITHOUT ANY WARRANTY; without even the implied warranty of
 
  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 
  GNU General Public License for more details.
 
@@ -349,30 +349,42 @@ void PlotManager::_addCurve(QwtPlotCurve
 
    curves.append(curve);
 

	
 
    unsigned index = curves.size()-1;
 
    auto color = infoModel->color(index);
 
    curve->setPen(color);
 

	
 
    // create the plot for the curve if we are on multi display
 
    Plot* plot;
 
    if (isMulti)
 
    {
 
        // create a new plot widget
 
        plot = addPlotWidget();
 
        plot->setDispChannels(QVector<const StreamChannel*>(1, _stream->channel(index)));
 
    }
 
    else
 
    {
 
        plot = plotWidgets[0];
 
        plot->setDispChannels(_stream->allChannels());
 
    }
 

	
 
    if (_stream != nullptr)     // not displaying snapshot
 
    {
 
        QVector<const StreamChannel*> dispChannels;
 
        if (isMulti)
 
        {
 
            dispChannels = QVector<const StreamChannel*>(1, _stream->channel(index));
 
        }
 
        else
 
        {
 
            dispChannels = _stream->allChannels();
 
        }
 
        plot->setDispChannels(dispChannels);
 
    }
 

	
 
    // show the curve
 
    curve->attach(plot);
 
    plot->replot();
 
}
 

	
 
void PlotManager::removeCurves(unsigned number)
 
{
 
    for (unsigned i = 0; i < number; i++)
 
    {
 
        if (!curves.isEmpty())
0 comments (0 inline, 0 general)