From 9c882a59aac2483232605b2816f4443efe3c1df2 Mon Sep 17 00:00:00 2001 From: f4exb Date: Thu, 1 Mar 2018 02:33:18 +0100 Subject: [PATCH] GLScopeNG: suppress VLAs --- sdrgui/gui/glscopeng.cpp | 43 ++++++++++++++++++++++++++++++---------- sdrgui/gui/glscopeng.h | 7 +++++++ 2 files changed, 40 insertions(+), 10 deletions(-) diff --git a/sdrgui/gui/glscopeng.cpp b/sdrgui/gui/glscopeng.cpp index 642b68a07..3210eff9b 100644 --- a/sdrgui/gui/glscopeng.cpp +++ b/sdrgui/gui/glscopeng.cpp @@ -213,7 +213,8 @@ void GLScopeNG::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 GLScopeNG::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 GLScopeNG::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 GLScopeNG::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 GLScopeNG::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 GLScopeNG::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 GLScopeNG::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 GLScopeNG::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 GLScopeNG::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 GLScopeNG::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 GLScopeNG::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 GLScopeNG::setUniqueDisplays() diff --git a/sdrgui/gui/glscopeng.h b/sdrgui/gui/glscopeng.h index c49d07c93..e28816e51 100644 --- a/sdrgui/gui/glscopeng.h +++ b/sdrgui/gui/glscopeng.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;