From e5ad63e9b38308a14fc42586a33bf95c4990359a Mon Sep 17 00:00:00 2001 From: f4exb Date: Thu, 1 Mar 2018 03:22:30 +0100 Subject: [PATCH] GLScopeMulti: suppress VLAs --- sdrgui/gui/glscopemulti.cpp | 43 ++++++++++++++++++++++++++++--------- sdrgui/gui/glscopemulti.h | 7 ++++++ 2 files changed, 40 insertions(+), 10 deletions(-) diff --git a/sdrgui/gui/glscopemulti.cpp b/sdrgui/gui/glscopemulti.cpp index e78a288a4..c963f63b2 100644 --- a/sdrgui/gui/glscopemulti.cpp +++ b/sdrgui/gui/glscopemulti.cpp @@ -213,7 +213,8 @@ void GLScopeMulti::paintGL() { tickList = &m_y1Scale.getTickList(); - GLfloat q3[4*tickList->count()]; + //GLfloat q3[4*tickList->count()]; + GLfloat *q3 = m_q3TickY1.m_array; int effectiveTicks = 0; for (int i= 0; i < tickList->count(); i++) @@ -243,7 +244,8 @@ void GLScopeMulti::paintGL() { tickList = &m_x1Scale.getTickList(); - GLfloat q3[4*tickList->count()]; + //GLfloat q3[4*tickList->count()]; + GLfloat *q3 = m_q3TickX1.m_array; int effectiveTicks = 0; for(int i= 0; i < tickList->count(); i++) { tick = &(*tickList)[i]; @@ -386,7 +388,8 @@ void GLScopeMulti::paintGL() { tickList = &m_y2Scale.getTickList(); - GLfloat q3[4*tickList->count()]; + //GLfloat q3[4*tickList->count()]; + GLfloat *q3 = m_q3TickY2.m_array; int effectiveTicks = 0; for (int i= 0; i < tickList->count(); i++) @@ -416,7 +419,8 @@ void GLScopeMulti::paintGL() { tickList = &m_x2Scale.getTickList(); - GLfloat q3[4*tickList->count()]; + //GLfloat q3[4*tickList->count()]; + GLfloat *q3 = m_q3TickX2.m_array; int effectiveTicks = 0; for(int i= 0; i < tickList->count(); i++) { tick = &(*tickList)[i]; @@ -566,7 +570,8 @@ void GLScopeMulti::paintGL() // Horizontal Y1 tickList = &m_y1Scale.getTickList(); { - GLfloat q3[4*tickList->count()]; + //GLfloat q3[4*tickList->count()]; + GLfloat *q3 = m_q3TickY1.m_array; int effectiveTicks = 0; for (int i= 0; i < tickList->count(); i++) @@ -594,7 +599,8 @@ void GLScopeMulti::paintGL() // Vertical X1 tickList = &m_x1Scale.getTickList(); { - GLfloat q3[4*tickList->count()]; + //GLfloat q3[4*tickList->count()]; + GLfloat *q3 = m_q3TickX1.m_array; int effectiveTicks = 0; for(int i= 0; i < tickList->count(); i++) { tick = &(*tickList)[i]; @@ -655,7 +661,8 @@ void GLScopeMulti::paintGL() // Horizontal Y2 tickList = &m_y2Scale.getTickList(); { - GLfloat q3[4*tickList->count()]; + //GLfloat q3[4*tickList->count()]; + GLfloat *q3 = m_q3TickY2.m_array; int effectiveTicks = 0; for(int i= 0; i < tickList->count(); i++) { tick = &(*tickList)[i]; @@ -782,7 +789,8 @@ void GLScopeMulti::paintGL() // Horizontal Y2 tickList = &m_y2Scale.getTickList(); { - GLfloat q3[4*tickList->count()]; + //GLfloat q3[4*tickList->count()]; + GLfloat *q3 = m_q3TickY2.m_array; int effectiveTicks = 0; for(int i= 0; i < tickList->count(); i++) { tick = &(*tickList)[i]; @@ -805,7 +813,8 @@ void GLScopeMulti::paintGL() // Vertical X2 tickList = &m_x2Scale.getTickList(); { - GLfloat q3[4*tickList->count()]; + //GLfloat q3[4*tickList->count()]; + GLfloat *q3 = m_q3TickX2.m_array; int effectiveTicks = 0; for(int i= 0; i < tickList->count(); i++) { tick = &(*tickList)[i]; @@ -871,7 +880,8 @@ void GLScopeMulti::paintGL() if(end - start < 2) start--; - GLfloat q3[2*(end - start)]; + //GLfloat q3[2*(end - start)]; + GLfloat *q3 = m_q3Polar.m_array; const float *trace0 = (*m_traces)[0]; memcpy(q3, &(trace0[2*start+1]), (2*(end - start) - 1)*sizeof(float)); // copy X values @@ -1018,6 +1028,19 @@ void GLScopeMulti::applyConfig() { setPolarDisplays(); } + + m_q3TickY1.allocate(4*m_y1Scale.getTickList().count()); + m_q3TickY2.allocate(4*m_y2Scale.getTickList().count()); + m_q3TickX1.allocate(4*m_x1Scale.getTickList().count()); + m_q3TickX2.allocate(4*m_x1Scale.getTickList().count()); + + int start = (m_timeOfsProMill/1000.0) * m_traceSize; + int end = std::min(start + m_traceSize/m_timeBase, m_traceSize); + + if(end - start < 2) + start--; + + m_q3Polar.allocate(2*(end - start)); } void GLScopeMulti::setUniqueDisplays() diff --git a/sdrgui/gui/glscopemulti.h b/sdrgui/gui/glscopemulti.h index 577008586..5466522a1 100644 --- a/sdrgui/gui/glscopemulti.h +++ b/sdrgui/gui/glscopemulti.h @@ -31,6 +31,7 @@ #include "gui/glshadertextured.h" #include "util/export.h" #include "util/bitfieldindex.h" +#include "util/incrementalarray.h" class QPainter; @@ -131,6 +132,12 @@ private: GLShaderTextured m_glShaderBottom2Scale; GLShaderTextured m_glShaderPowerOverlay; + IncrementalArray m_q3Polar; + IncrementalArray m_q3TickY1; + IncrementalArray m_q3TickY2; + IncrementalArray m_q3TickX1; + IncrementalArray m_q3TickX2; + static const int m_topMargin = 5; static const int m_botMargin = 20; static const int m_leftMargin = 35;