From c06f9f4ea885a44c5e3f8291b00aa5b7487a1179 Mon Sep 17 00:00:00 2001
From: Jon Beniston <jon@beniston.com>
Date: Mon, 20 Jun 2022 15:23:51 +0100
Subject: [PATCH] Spectrum: Prevent null texture warning when only histogram is
 displayed

---
 sdrgui/gui/glspectrum.cpp | 9 ++++++---
 1 file changed, 6 insertions(+), 3 deletions(-)

diff --git a/sdrgui/gui/glspectrum.cpp b/sdrgui/gui/glspectrum.cpp
index 87c0d0d50..29b78d4e5 100644
--- a/sdrgui/gui/glspectrum.cpp
+++ b/sdrgui/gui/glspectrum.cpp
@@ -1898,7 +1898,6 @@ void GLSpectrum::applyChanges()
     if (m_nbBins <= 0) {
         return;
     }
-
     QFontMetrics fm(font());
     int M = fm.horizontalAdvance("-");
 
@@ -2581,7 +2580,9 @@ void GLSpectrum::applyChanges()
         m_waterfallBuffer = new QImage(m_nbBins, m_waterfallHeight, QImage::Format_ARGB32);
 
         m_waterfallBuffer->fill(qRgb(0x00, 0x00, 0x00));
-        m_glShaderWaterfall.initTexture(*m_waterfallBuffer);
+        if (m_waterfallHeight > 0) {
+            m_glShaderWaterfall.initTexture(*m_waterfallBuffer);
+        }
         m_waterfallBufferPos = 0;
 
         if (m_3DSpectrogramBuffer) {
@@ -2591,7 +2592,9 @@ void GLSpectrum::applyChanges()
         m_3DSpectrogramBuffer = new QImage(m_nbBins, m_waterfallHeight, QImage::Format_Grayscale8);
 
         m_3DSpectrogramBuffer->fill(qRgb(0x00, 0x00, 0x00));
-        m_glShaderSpectrogram.initTexture(*m_3DSpectrogramBuffer);
+        if (m_waterfallHeight > 0) {
+            m_glShaderSpectrogram.initTexture(*m_3DSpectrogramBuffer);
+        }
         m_3DSpectrogramBufferPos = 0;
     }
     m_glShaderSpectrogram.initColorMapTexture(m_3DSpectrogramColorMap);