Commit 6dddef1f7a21ab490c3500246460fd3a5bb73703
Committed by
David Gräff
1 parent
16dc684e
Fix segfaults in XY display
Showing
2 changed files
with
33 additions
and
27 deletions
openhantek/src/glscope.cpp
| @@ -275,7 +275,9 @@ void GlScope::paintGL() { | @@ -275,7 +275,9 @@ void GlScope::paintGL() { | ||
| 275 | unsigned historyIndex = 0; | 275 | unsigned historyIndex = 0; |
| 276 | for (Graph &graph : m_GraphHistory) { | 276 | for (Graph &graph : m_GraphHistory) { |
| 277 | for (ChannelID channel = 0; channel < scope->voltage.size(); ++channel) { | 277 | for (ChannelID channel = 0; channel < scope->voltage.size(); ++channel) { |
| 278 | - drawSpectrumChannelGraph(channel, graph, (int)historyIndex); | 278 | + if (scope->horizontal.format == Dso::GraphFormat::TY) { |
| 279 | + drawSpectrumChannelGraph(channel, graph, (int)historyIndex); | ||
| 280 | + } | ||
| 279 | drawVoltageChannelGraph(channel, graph, (int)historyIndex); | 281 | drawVoltageChannelGraph(channel, graph, (int)historyIndex); |
| 280 | } | 282 | } |
| 281 | ++historyIndex; | 283 | ++historyIndex; |
openhantek/src/glscopegraph.cpp
| @@ -26,39 +26,43 @@ void Graph::writeData(PPresult *data, QOpenGLShaderProgram *program, int vertexL | @@ -26,39 +26,43 @@ void Graph::writeData(PPresult *data, QOpenGLShaderProgram *program, int vertexL | ||
| 26 | vaoVoltage.resize(data->vaChannelVoltage.size()); | 26 | vaoVoltage.resize(data->vaChannelVoltage.size()); |
| 27 | vaoSpectrum.resize(data->vaChannelSpectrum.size()); | 27 | vaoSpectrum.resize(data->vaChannelSpectrum.size()); |
| 28 | for (ChannelID channel = 0; channel < vaoVoltage.size(); ++channel) { | 28 | for (ChannelID channel = 0; channel < vaoVoltage.size(); ++channel) { |
| 29 | - VaoCount &v = vaoVoltage[channel]; | ||
| 30 | - VaoCount &s = vaoSpectrum[channel]; | ||
| 31 | int dataSize; | 29 | int dataSize; |
| 32 | 30 | ||
| 33 | // Voltage channel | 31 | // Voltage channel |
| 34 | - if (!v.first) { | ||
| 35 | - v.first = new QOpenGLVertexArrayObject; | ||
| 36 | - if (!v.first->create()) throw new std::runtime_error("QOpenGLVertexArrayObject create failed"); | 32 | + if (channel < vaoVoltage.size()) { |
| 33 | + VaoCount &v = vaoVoltage[channel]; | ||
| 34 | + if (!v.first) { | ||
| 35 | + v.first = new QOpenGLVertexArrayObject; | ||
| 36 | + if (!v.first->create()) throw new std::runtime_error("QOpenGLVertexArrayObject create failed"); | ||
| 37 | + } | ||
| 38 | + ChannelGraph &gVoltage = data->vaChannelVoltage[channel]; | ||
| 39 | + v.first->bind(); | ||
| 40 | + dataSize = int(gVoltage.size() * sizeof(QVector3D)); | ||
| 41 | + buffer.write(offset, gVoltage.data(), dataSize); | ||
| 42 | + program->enableAttributeArray(vertexLocation); | ||
| 43 | + program->setAttributeBuffer(vertexLocation, GL_FLOAT, offset, 3, 0); | ||
| 44 | + v.first->release(); | ||
| 45 | + v.second = (int)gVoltage.size(); | ||
| 46 | + offset += dataSize; | ||
| 37 | } | 47 | } |
| 38 | - ChannelGraph &gVoltage = data->vaChannelVoltage[channel]; | ||
| 39 | - v.first->bind(); | ||
| 40 | - dataSize = int(gVoltage.size() * sizeof(QVector3D)); | ||
| 41 | - buffer.write(offset, gVoltage.data(), dataSize); | ||
| 42 | - program->enableAttributeArray(vertexLocation); | ||
| 43 | - program->setAttributeBuffer(vertexLocation, GL_FLOAT, offset, 3, 0); | ||
| 44 | - v.first->release(); | ||
| 45 | - v.second = (int)gVoltage.size(); | ||
| 46 | - offset += dataSize; | ||
| 47 | 48 | ||
| 48 | // Spectrum channel | 49 | // Spectrum channel |
| 49 | - if (!s.first) { | ||
| 50 | - s.first = new QOpenGLVertexArrayObject; | ||
| 51 | - if (!s.first->create()) throw new std::runtime_error("QOpenGLVertexArrayObject create failed"); | 50 | + if (channel < vaoSpectrum.size()) { |
| 51 | + VaoCount &s = vaoSpectrum[channel]; | ||
| 52 | + if (!s.first) { | ||
| 53 | + s.first = new QOpenGLVertexArrayObject; | ||
| 54 | + if (!s.first->create()) throw new std::runtime_error("QOpenGLVertexArrayObject create failed"); | ||
| 55 | + } | ||
| 56 | + ChannelGraph &gSpectrum = data->vaChannelSpectrum[channel]; | ||
| 57 | + s.first->bind(); | ||
| 58 | + dataSize = int(gSpectrum.size() * sizeof(QVector3D)); | ||
| 59 | + buffer.write(offset, gSpectrum.data(), dataSize); | ||
| 60 | + program->enableAttributeArray(vertexLocation); | ||
| 61 | + program->setAttributeBuffer(vertexLocation, GL_FLOAT, offset, 3, 0); | ||
| 62 | + s.first->release(); | ||
| 63 | + s.second = (int)gSpectrum.size(); | ||
| 64 | + offset += dataSize; | ||
| 52 | } | 65 | } |
| 53 | - ChannelGraph &gSpectrum = data->vaChannelSpectrum[channel]; | ||
| 54 | - s.first->bind(); | ||
| 55 | - dataSize = int(gSpectrum.size() * sizeof(QVector3D)); | ||
| 56 | - buffer.write(offset, gSpectrum.data(), dataSize); | ||
| 57 | - program->enableAttributeArray(vertexLocation); | ||
| 58 | - program->setAttributeBuffer(vertexLocation, GL_FLOAT, offset, 3, 0); | ||
| 59 | - s.first->release(); | ||
| 60 | - s.second = (int)gSpectrum.size(); | ||
| 61 | - offset += dataSize; | ||
| 62 | } | 66 | } |
| 63 | 67 | ||
| 64 | buffer.release(); | 68 | buffer.release(); |