Skip to content

Commit

Permalink
WVUMeterGL: fix initial rendering of meters invisble after skin load
Browse files Browse the repository at this point in the history
  • Loading branch information
ronso0 committed Nov 8, 2022
1 parent 5fa2f16 commit c4ea28d
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 6 deletions.
10 changes: 6 additions & 4 deletions src/widget/wvumetergl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
WVuMeterGL::WVuMeterGL(QWidget* parent)
: QGLWidget(parent, SharedGLContext::getWidget()),
WBaseWidget(this),
m_bHasRendered(false),
m_iNeedsRender(1),
m_bSwapNeeded(false),
m_dParameter(0),
m_dPeakParameter(0),
Expand Down Expand Up @@ -159,7 +159,7 @@ void WVuMeterGL::paintEvent(QPaintEvent* e) {
// Force a rerender when render is called from the vsync thread, e.g. to
// git rid artifacts after hiding and showing the mixer or incomplete
// initial drawing.
m_bHasRendered = false;
m_iNeedsRender = 2;
}

void WVuMeterGL::showEvent(QShowEvent* e) {
Expand All @@ -173,7 +173,7 @@ void WVuMeterGL::render(VSyncThread* vSyncThread) {

updateState(vSyncThread->sinceLastSwap());

if (m_bHasRendered && m_dParameter == m_dLastParameter &&
if (m_iNeedsRender == 0 && m_dParameter == m_dLastParameter &&
m_dPeakParameter == m_dLastPeakParameter) {
return;
}
Expand Down Expand Up @@ -294,7 +294,9 @@ void WVuMeterGL::render(VSyncThread* vSyncThread) {

m_dLastParameter = m_dParameter;
m_dLastPeakParameter = m_dPeakParameter;
m_bHasRendered = true;
if (m_iNeedsRender > 0) {
m_iNeedsRender--;
}
m_bSwapNeeded = true;
}

Expand Down
5 changes: 3 additions & 2 deletions src/widget/wvumetergl.h
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,9 @@ class WVuMeterGL : public QGLWidget, public WBaseWidget {
void showEvent(QShowEvent* /*unused*/) override;
void setPeak(double parameter);

// To make sure we render at least once even when we have no signal
bool m_bHasRendered;
// To make sure we render at least N times even when we have no signal,
// for example after showEvent()
int m_iNeedsRender;
// To indicate that we rendered so we need to swap
bool m_bSwapNeeded;
// Current parameter and peak parameter.
Expand Down

0 comments on commit c4ea28d

Please sign in to comment.